Reputation: 7739
I have this in my file:
export default withAuth(authOptions)(ProfilePage);
But I also need to export this:
function mapStateToProps (state) {
const { isLoggedIn } = state
return { isLoggedIn}
}
const mapDispatchToProps = dispatch =>
bindActionCreators({ logInUser }, dispatch)
export default connect(
mapStateToProps,
mapDispatchToProps
)(ProfilePage)
I can I combine them so they both work?
Upvotes: 0
Views: 219
Reputation: 15292
You can using JS#named export
.
export const mapStateToProps = (state)=> {
const { isLoggedIn } = state
return { isLoggedIn}
}
export const mapDispatchToProps = dispatch =>bindActionCreators({ logInUser }, dispatch)
now import it in other file
//test.js
import ProfilePage,{mapStateToProps ,mapDispatchToProps} from "path_to_file"
Upvotes: 1