I want to export the 'hscnumber' variable here to another file. How can I do it?
export default class test extends React.Component { constructor(props) { super(props); this.getData(); this.state = { h:0, hscnumber:0, }; }
By another file you mean another screen and you are using react navigation then you can use react Navigation's params to pass the data from screen to screen
props.navigation.navigate("screen2",{data:hscnumber})
And on screen 2
console.log("mydata",props.route.params.data)
If you want to pass data to components you can simply pass it by props
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.