im trying to change the state using this but everyTime it takes add function only how to make the state change onPress ..what can i do please let me know
component //
<Searchitems
key={index}
crypto={crypto}
multipletest={multipletest}
remove={crypto => remove(crypto)}
add={crypto => add(crypto)}
// status={status}
removes="Remove"
adds="Add"
/>
const [statusss, setStatus] = React.useState(false);
onPress={() =>
setStatus(!statusss) ? props.remove(crypto) : props.add(crypto)
}
CodePudding user response:
As mentioned in my comment, it is a bit difficult to understand what you are trying to do with your code. But still, try it like this. It appears that you are trying to check condition on a function.
const [statusss, setStatus] = React.useState(false);
useEffect(() => {
statusss ? props.remove(crypto) : props.add(crypto)
}, [statusss]);
<SomeComponent
onPress={() => setStatus(!statusss)}
/>