Beginner here. I'm struggling to pass my useState variable to another screen in my React Native project. The screen that contains the variable, "screenCheckboxes.js" is structured like
export default function screenCheckboxes({ navigation }) {
const [check, setCheck] = useState(false);
const toggleCheck = () => setCheck(previousState => !previousState);
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Hello from Checkbox Screen</Text>
<Switch
onValueChange={toggleCheck}
value={check}
/>
</View>
);
}
I want to render an image on another screen file, depending on if the checkbox switch is checked on or not. I figured I will be importing the checkbox screen using import { check } from './screenCheckboxes.js';
How would I go about using my "check" useState in another screen?