Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

Why props is not working with my child component React JS (react native)

$
0
0

So this is in my main class where I am trying to render a modal from a child component.

<NewModal              transparent={true}            show={props.show}></NewModal>

show is initially set as false in the parent constructor and after one of my elements in my flatList is pressed I set show to trueHowever I am not sure why it is not working so well, here is my child class, I have tried lots of varients with the props and nothing seems to be working, the best I can get is the modal showing before I even press on one of my elements in the flat list.

Child component:

 const NewModal = (props) => {   return (<Modal transparent={true} visible={props.show}  ><View style={styles.modalView}><View><Text>Modal Text</Text></View><Button title="Back" onPress={() => visible=false } /></View></Modal>  );

};

 const styles = StyleSheet.create({ modalView: {  marginTop: 100,  height: "70%",  width: "95%",  alignSelf: "center",  borderRadius: 5,  borderWidth: 0.1,  shadowOpacity: 0.7,  backgroundColor: "white", }, });  export default NewModal; 

Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>