export default connect(
mapStateToProps,
{ login }
)(LoginModal); все работает отлично, но тогда не работает модальное
showRegister: () => {
dispatch(showModal('REGISTER', {}));
},
import React, { PureComponent } from 'react';
import axios from "axios";
import { connect } from 'react-redux';
import Login from '../../components/Login';
import Modal from '../../components/Modal';
import { hideModal, showModal, login } from '../../actions';
class LoginModal extends PureComponent {
constructor() {
super();
this.state = {
user_details: {},
goToMainPage: false
};
}
componentDidMount() {
if (this.props.isAuthenticated) {
this.loadUserDetail();
}
}
loadUserDetail = () => {
axios.get("/api/users/current_user/").then(res => {
this.setState({ user_details: res.data }, () => {
this.checkNotificationsStatus();
this.connectNotificationSocket(this.state.user_details.username);
});
});
};
submitSignIn = data =>
this.props.login(data).then(() => {
this.loadUserDetail();
this.setState({
goToMainPage: true
});
this.setState({
goToMainPage: false
});
});
render() {
return (
<Modal onClose={this.props.handleClose}>
<Login
submit={this.submitSignIn}
showRegister={this.props.showRegister}
showForgot={this.props.showForgot}
/>
</Modal>
)
}
}
const mapStateToProps = state => ({
isAuthenticated: !!state.user.token
});
const mapDispatchToProps = dispatch => ({
handleClose: () => {
dispatch(hideModal());
},
showRegister: () => {
dispatch(showModal('REGISTER', {}));
},
showForgot: () => {
dispatch(showModal('FORGOT', {}));
},
login: () => {
dispatch(login())
}
});
export default connect(
mapStateToProps,
mapDispatchToProps
)(LoginModal);
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-loader": "^8.0.4",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1"
}
{
"presets": ["react","env"]
}
const SomeComponent = ({ settings}) => (
<Settings />
);
const SomeComponent = ({ followers}) => (
<followers />
);