Question: I have three buttons using the same click handler. - My desire is to only change the color of one button when clicked.

If another button is clicked I want the previously clicked button to go back to the color 'blue' (original state).

Example code below:

```
import React, { useState } from 'react';

export default function App() {
    const [state, setState] = useState({
        name: 'bob',
        color: 'blue',
    });

    const handleColor = (e) => {
        setState((state) => ({
            ...state,
            color: 'red',
        }));
    };

    return (
        <div>
         <button style={{ backgroundColor: state.color }} onClick={handleColor}>Click Me</button>
         <button style={{ backgroundColor: state.color }} onClick={handleColor}>Click Me 2</button>
         <button style={{ backgroundColor: state.color }} onClick={handleColor}>Click Me 3</button>
        </div>
    );
}

```

Answer: 
Are you looking something like this

```
const lists = [
  { id: 1, title: "Click 1" },
  { id: 2, title: "Click 2" },
  { id: 3, title: "Click 3" }
];
export default function App() {
  const [selected, setSelected] = useState(0);
  const [state, setState] = useState({
    name: "bob",
    color: "blue"
  });

  const handleColor = (row) => {
    setSelected(row.id);
  };

  return (
    <div>
      {lists.map((list) => (
        <button
          key={list.id}
          onClick={() => handleColor(list)}
          style={{ backgroundColor: list.id === selected ? "red" : "" }}
        >
          {list.title}
        </button>
      ))}
    </div>
  );
}

```

[Live working demo](https://codesandbox.io/s/nervous-hawking-59ds2?file=/src/App.js:64-684)
you have to maintain separate state for each button.
you can do something like this

```
import React, { useState } from 'react';

export default function Parent() {

    const initialButtonState = {
        color1: 'blue',
        color2: 'blue',
        color3: 'blue',
    } 

    const [state, setState] = useState({...initialButtonState , name: 'bob'});

    const handleColor = (colorName) => {
        setState((state) => ({
            ...state,
            ...initialButtonState ,
            [colorName] : 'red'
        }));
    };

    return (
        <div>
         <button style={{ backgroundColor: color1 }} onClick={ () => handleColor("color1))}>Click Me</button>
         <button style={{ backgroundColor: color2 }} onClick={() => handleColor("color2")}>Click Me 2</button>
         <button style={{ backgroundColor: color3 }} onClick={() => handleColor("color3")}>Click Me 3</button>
        </div>
    );
}

```