How to set navigationOptions on stateless component with Typescript

后端 未结 4 1265
有刺的猬
有刺的猬 2020-12-16 13:18

I have a react component like

const Example = () => (...);

Using react-navigation I would normally apply naviga

4条回答
  •  独厮守ぢ
    2020-12-16 13:41

    You can use the following:

    import {
      NavigationScreenProps,
      NavigationScreenComponent
    } from 'react-navigation'
    
    interface Props extends NavigationScreenProps {
      // ... other props
    }
    
    const MyScreen: NavigationScreenComponent = ({ navigation }) => {
      // ... your component
    }
    
    MyScreen.navigationOptions = {
      // ... your navigation options
    }
    
    export default MyScreen
    
    

提交回复
热议问题