Passing props to react-redux container component

后端 未结 4 1732
温柔的废话
温柔的废话 2021-01-30 05:08

I have a react-redux container component that is created within a React Native Navigator component. I want to be able to pass the navigator as a prop to this container component

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-30 05:28

    Using Decorators (@)

    If you are using decorators, the code below give an example in the case you want to use decorators for your redux connect.

    @connect(
        (state, ownProps) => {
            return {
                Foo: ownProps.Foo,
            }
        }
    )
    export default class Bar extends React.Component {
    

    If you now check this.props.Foo you will see the prop that was added from where the Bar component was used.

    
    

    In this case this.props.Foo will be the string 'Baz'

    Hope this clarifies some things.

提交回复
热议问题