title: I want to toggle between default color and "blue" colors when I click on button in ReactJS
body: <p>I want to toggle the colors of my h1 tag. I can change the color one time to specific color. But I want to take the color to previous color when I click again.I used <code>useState</code> for that. In <code>useState</code> selected gives me true and false. According to true and false I create if statement and change the color. Here is my code</p>
  <pre><code>import './App.css';
  import React, { useState } from 'react';
  
  function Deneme() {
    const [color,setColor]=useState('red');
    const [selected, setSelected] = useState(false)
    const [textColor,setTextColor]=useState('white');
    if(!selected){
      setColor(&quot;blue&quot;)
    }
    return (
      &lt;div className=&quot;App&quot;&gt;
        &lt;button style={{background:color}} className='btn btn-primary' onClick={()=&gt;{setTextColor('red');setSelected(!selected)}}&gt;Click here&lt;/button&gt;
        &lt;h1 style={{color:color}}&gt;Change Color&lt;/h1&gt;
      &lt;/div&gt;
    );
  }
  
  export default Deneme;
  </code></pre>