LOs

Higher-Order Component (HOC)

Higher-order components, or HOCs, receive a React component as an argument and return a new component.

Ex:

  1. ProtectedRoute- This will redirect a user to the /login if there is no currentUserId
  export const ProtectedRoute = ({ component: Component, path, currentUserId, exact }) => {
    return (
      <Route
        path={path}
        exact={exact}
        render={(props) =>
          currentUserId ? <Component {...props} /> : <Redirect to="/login" />
        }
      />
    );
  };
  1. AuthRoute- This will redirect a user to / if there is a currentUserId
  export const AuthRoute = ({ component: Component, path, currentUserId, exact }) => {
    return (
      <Route
        path={path}
        exact={exact}
        render={(props) =>
          currentUserId ? <Redirect to="/" /> : <Component {...props} />
        }
      />
    );
  };

React-Redux Library

We use the React-Redux library to improve how React Components interact with the Redux store.

The React-Redux library has two main parts- The <Provider /> component and connect function.

To use the React-Redux library we must * npm install react-redux

Other installs in this lesson: * redux-logger * redux-thunk

Lecture Videos

Lecture Video Google Drive Folder

Solutions

Giphy Redux Solutions

Giphy Redux Solutions Zip

Pokedex Redux Solutions

Pokedex Redux Solutions Zip