1

I'm new to React Native, How to export default two components,

I have a class which use withNavigation and redux connect, and I have to export them as default to work properly.

import { withNavigation } from 'react-navigation';
import { connect } from 'react-redux';
.
.
.
export default connect(mapStateToProps, mapDispatchToProps)(ClassName);

export default withNavigation(ClassName)

2 Answers 2

1

Please use compose from 'redux'

import {compose} from 'redux'
...
export default compose(
   connect(mapStateToProps, mapDispatchToProps),
   withNavigation
)(ClassName)
Sign up to request clarification or add additional context in comments.

Comments

1

You must wrap your component by all higher-order functions to use all of them:

export default connect(mapStateToProps, mapDispatchToProps)(withNavigation(ClassName));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.