I'm having trouble passing state from a component to main screen in react-native
for example
MainScreen.js
const MainScreen = () => {
return (
<>
<AdButton/>
<Text>{adCreated}</Text>
</>
)
}
AdButton.js
const [adCreated, createAd] = useState(false);
const adButton = () => {
createAd(true);
}
const AdButton = () => {
return (
<TouchableOpacity onPress={adButton}>Create an Ad</TouchableOpacity>
)
}
How can I have the state of adCreated show true on MainScreen when the state is changed in the AdButton Component.
Thanks,
Arnav