title: Can't Perform a React State update on a unmounted component when passing a state as an prop to the child component
body: <p>I am trying to pass a state to the child component.</p>
  <p>The State is for</p>
  <pre><code>loading state
  </code></pre>
  <p>Inside the parent component As you can see I am passing set loading as prop</p>
  <pre><code>const [loading, setLoading] = useState(true);
  
  return (
  &lt;View&gt;
   &lt;IndividualProduct
               info={item[i]}
               index={i}
               key={i}
               fav={true}
               stateChange={stateChange}
               setLoading={setLoading}
               loading={loading}/&gt;
  &lt;/View&gt;
  )
  </code></pre>
  <p>Inside the child component
  I am getting the props like this</p>
  <pre><code>const IndividualProduct = ({info, index, fav, stateChange, setLoading}) =&gt; {
     const dispatch = useDispatch();
  
    const token = useSelector((state) =&gt; state.authReducer.token);
    const favoriteList = useSelector(
      (state) =&gt; state.productReducer.favoriteList,
    );
  
  const addToFav = (IdToSend) =&gt; {
      if (token == '') {
        alert('Please sign in to add this product as your favourite.');
      } else {
        setLoading(true);
        let dataToSend = {
          ProductId: `${IdToSend}`,
          ProductLanguageId: 'LANG1',
          ProductVariantId: '',
        };
        dispatch(addFavorite(token.access_token, dataToSend)).then((res) =&gt; {
          dispatch(fetchFavorite(tokenData));
          setFavorite(true);
          setLoading(false);
        });
      }
    };
  
  
  
  return(&lt;View&gt;   
  &lt;TouchableOpacity onPress={() =&gt; addToFav(info.id)}
                style={{justifyContent: 'flex-end', alignItems: 'flex-end'}}&gt;
                &lt;Icon2 name=&quot;star-o&quot; color=&quot;#4684A0&quot; size={40} /&gt;
              &lt;/TouchableOpacity&gt;
  &lt;/View&gt;)
  </code></pre>
  <p>As you can see I am calling the setLoading when ever I press the button. But when ever its finish</p>
  <p>I getting this message</p>
  <pre><code>Can't perform a React state update on an unmounted component.
  This is a no-op, but it indicates a memory leak in your application.
  To fix, cancel all subscriptions
  </code></pre>