title: Making my function general as possible for checking a state
body: <p>I want to create a function that can be general as possible but It doesn't work now.</p>
  
  <p>I have two case : </p>
  
  <ul>
  <li><p>Check if the state of a state is not empty or true and if my item is equal to him, I want to reset him by calling <code>resetState()</code> and set to false and empty string</p></li>
  <li><p>Check if the state of a state is not empty and if my item is equal to him, I want to reset him by calling resetState()and the empty string</p></li>
  </ul>
  
  <p>My problem is : I try to replace <code>stateItem.checkedA</code> by something like <code>stateItem.item</code> to avoid repetitions but doesn't work for me, is it possible in react to do that ? </p>
  
  <p>This is what I have :</p>
  
  <pre><code>const [stateBoolean, setStateBoolean] = React.useState({
      checkedA: false,
      checkedB: false
    });
  
  const [stateItem, setStateItem] = React.useState({
      checkedA: "",
      checkedB: "toto",
      checkedC: "onlyHere not in Boolean"
    });
  
    const check = (listState) =&gt; {
      listState.map(item =&gt; {
        (stateBoolean.checkedA === true || stateItem.checkedA !== "") &amp;&amp;
        item === "checkedA"
          ? (resetChange("checkedA", "stateItem"),
            resetChange("checkedA", "stateBoolean"))
          : null;
        (stateBoolean.checkedB === true || stateItem.checkedB !== "") &amp;&amp;
        item === "checkedB"
          ? (resetChange("checkedB", "stateItem"), resetChange("checkedB", "stateBoolean"))
          : null;
        stateItem.checkedC !== "" &amp;&amp; item === "checkedC"
          ? resetChange("checkedC", "stateItem")
          : null;
      });
    };
  </code></pre>
  
  <p>What I expected, but not working:</p>
  
  <pre><code>const checkWanted = (listState) =&gt; {
      listState.map(item =&gt; {
        (stateBoolean.item === true || stateItem.item !== "") &amp;&amp;
        (item === "checkedB" || item === "checkedA")
          ? (resetChange(item, "stateItem"), resetChange(item, "stateBoolean"))
          : null;
        stateItem.checkedEOther !== "" &amp;&amp; item === "checkedEOther"
          ? resetChange(item, "stateItem")
          : null;
      });
    };
  </code></pre>
  
  <p>Any idea?</p>