react-nativecomponentsredux-actions

Can pure component use redux actions?


I have a FlatList which I would like to optimize by using pure components.

As I am new to react-Native I am not sure how pure component will act in a situation were actions(functions) will be passed as props.

I know that their benefit is reached by shalow comparison of state and props which prevents rerender but I am not sure how a redz action will affect.

I assume that since it doesn't change it won't affect the performance.

Is this assumption is correct?


Solution

  • FlatList is already a PureComponent and I would definitely not suggest to optimize it in this way as you can easily run into bugs. It already takes care of rerendering things when necessary. But answering your question - same redux action is the same function across rerenders, you can comfirm it with console.log(this.props.myAction === this.props.myAction)