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

How create a react-native custom view with typescript

$
0
0

I want to create a custom view with react-native-modal in my custom view:

type Props = {isVisible: boolean;setVisible: void }<Modal isVisible={props.visible}......><Button title="colse" onPress={()=> props.setVisible}>

Then in my page:

const [isVisible,setVisible]= React.useState(false)const onClick= () =>{setVisible(!isVisible)}<MyView visible={isVisible} setVisible={onClick}/>

But when I click the button, nothing happens and there is no error.

If I change the code like this:

const [isVisible,setVisible]= React.useState(true)

the dialog will be shown at first, but cannot close.

I hope someone can give me an example of how to do that.


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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