score:0

  const buttonTwoBackgroundColor = () => {
    setButtonTwo("red")
  }

score:0

    import React, { useState } from "react";
import { Button } from "antd";
import "./styles.css";

export default function App() {
 

     const [buttonOne, setButtonOne] = useState("red");
    
      const [buttonTwo, setButtonTwo] = useState({backgroundColor: "blue", border: "blue"});
    
      const buttonTwoBackgroundColor = () => {
       setButtonTwo(prevState => ({
        ...prevState,
        backgroundColor: 'blue',
        border: 'red'
     }));
      };
      return (
        <div>
          <Button
            style={{ backgroundColor: buttonOne, border: buttonOne }}
            className="one"
            type="primary"
          >
            First
          </Button>
          <Button
            style={{ backgroundColor: buttonTwo.backgroundColor, border: buttonTwo.border }}
            onClick={buttonTwoBackgroundColor}
            className="two"
            type="primary"
          >
            Second
          </Button>
        </div>
      );
    }

Related Query

More Query from same tag