title: DropDown State not preserving in React
body: <p>I have A react DropDown Component as shown below:
  <a href="https://i.stack.imgur.com/THSEp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/THSEp.png" alt="enter image description here" /></a></p>
  <p>Everything works fine when I make selections as shown below:
  <a href="https://i.stack.imgur.com/eKTIq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eKTIq.png" alt="enter image description here" /></a></p>
  <p><strong><a href="https://codesandbox.io/s/nice-wozniak-6js06?file=/src/App.js" rel="nofollow noreferrer">Reproduction Link</a></strong></p>
  <p>Now here comes the problem, my dropdown open close handler works but each time it closes and reopens the previous values, even though they're preserved in <code>console log</code> but they don't show up in UI.</p>
  <pre><code>DropDownControlHandler = (handleElem) =&gt;
      {
          const newState = this.state;
          
          newState.isDropDownOpen = handleElem; 
  
          console.log(this.DropDownElements);
   
          this.setState({state: newState,DropDownElements: this.DropDownElements});
          //this.CheckBoxChangeHandler(-10,this.DropDownElements);
          
  
      }
  
      CheckBoxChangeHandler = (index) =&gt; {
  
          
          let newData = this.DropDownElements;
          if(!this.state.isMultiSelectOn)
          { 
              console.log(&quot;Executing if&quot;);
              newData = this.ClearAllElements;
              console.log(newData);
          }
  
          newData[index].isChecked = !(newData[index].isChecked);
          console.log(&quot;New Data:- &quot;);
          console.log(newData);
          this.setState({DropDownElements: newData});
          
  
      }
  </code></pre>
  <p>Can someone help me here? Here is the <a href="https://codesandbox.io/s/nice-wozniak-6js06?file=/src/App.js" rel="nofollow noreferrer">reproduction link</a>.</p>
  <p>End Goal: On Closing and opening dropdown, the data should preserve and when <code>isMultiSelectOn</code> false then only one selection should happen and not others.</p>