We have added redux to our application so we can leverage all the benefits that come with uni-directional data flow. Instead of the prop drilling we would have to do in order to pass our new user object down deeper into our component trees from our app, we can now just connect those components directly to our redux store where we store all our data.
import React from "react"; import "./App.css"; import HomePage from "./pages/homepage/homepage-component"; import { Switch, Route } from "react-router-dom"; import ShopPage from "./pages/shop/shop.component"; import Header from "./components/header/header.component"; import SignInAndSignUpPage from "./pages/sign-in-and-sign-up/sign-in-and-sign-up.component"; import { auth, createUserProfileDocument } from "./firebase/firebase.utils"; import { connect } from "react-redux"; import { setCurrentUser } from "./redux/user/user.actions";
class App extends React.Component { unsubscribeFromAuth = null;
componentDidMount() { const { setCurrentUser } = this.props;
}
componentWillUnmount() { this.unsubscribeFromAuth(); }
render() { return (
} } const mapDispatchToProps = dispatch => ({ setCurrentUser: user => dispatch(setCurrentUser(user)) });
export default connect(null, mapDispatchToProps)(App);
Unhandled Rejection (TypeError): Object(...) is not a function in this line of code setCurrentUser: user => dispatch(setCurrentUser(user))
please help. i cannot find any help after searching in stackoverflow. @ZhangMYihua please help I am unable to proceed further in your course.