-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
re-render when user react-native NavigationExperimental/NavigationLegacyNavigator.js #365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you provide an example that reproduces this? |
this example toggle navigator can reproduces. |
I don’t know React Native well. How do I launch this repo? |
Do you ever try any React Native project, even Get started project? |
Yeah. But usually they come with Xcode projects, don’t they? |
Okay, I got it to run. Can you please clarify which exactly actions you do not expect to cause components to re-render? |
If I change renderList(list) {
let result = [];
list.map(i => {
result.push(<TouchableOpacity key={i.id} style={styles.row} onPress={() => {
this.props.dispatch({
type: 'test'
})
}}><Text>{i.title}</Text></TouchableOpacity>);
});
return result;
} Therefore, “any action” does not cause “all container components” to re-render, so it looks like there is no bug here. When I run the app for the first time, I see this:
It looks correct to me: we first render the initial state, which is an empty screen, then we If I open a post’s comments, I see this:
The initial The one that doesn’t quite make sense to me is I dug into why this happens, and it seems like returning a cached element in I don’t fully understand in which cases this happens yet so I’ll file a separate issue for the future. Option 1Remove function mapStateToProps(state) { // , ownProps
let {list, isFetching} = state.postList || {isFetching:true};
return {
isFetching,
list
};
} Option 2Add a custom import shallowCompare from 'react-addons-shallow-compare'
class Post extends Component {
shouldComponentUpdate(nextProps, nextState) {
return shallowCompare(this, nextProps, nextState)
} I hope this helps! |
Great! your answer is prefect for me. thanks:) |
fix subordinate clause syntax
When use NavigationExperimental/NavigationLegacyNavigator.js as navigator, all container components connected to redux store rendered by any action.
Old navigator has not this problem.
The text was updated successfully, but these errors were encountered: