web icon indicating copy to clipboard operation
web copied to clipboard

pass function into Header or Custom Navigators in react native web?

Open blinky9 opened this issue 6 years ago • 1 comments

Hi, In native react navigation, we can use navigation.setParams to pass our functions into Header (by using navigationOptions and navigation.getParam as described in this)

But on the web, setParams does not work properly and serialize function into query-strings and urls get very messy.

Is there any better way to pass function into Header or Custom Navigators in react native web?

blinky9 avatar Dec 29 '19 11:12 blinky9

@blinky9 A better way to handle this is to have the constructor or componentDidMount assign the function to a file level scoped variable that then would get used in your navigationOptions callback. Would have to have a dummy function assigned or check for undefined/null in case navigationOptions gets called before componentDidMount/constructor.

509dave16 avatar Mar 12 '20 18:03 509dave16