Skip to content

React - Redux - Firebase: Master React from A to Z - Create your own NETFLIX. (Demo on Heroku)

Notifications You must be signed in to change notification settings

Raigyo/react-netflix-clone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React - Redux - Firebase: Master React from A to Z - Create your own NETFLIX

react-redux logo

April / May 2020

🔨 All React in Depth from scratch, with Redux, React Router DOM, Firebase, Paypal (Sand Box), React Player, themoviedb. From Udemy 'Maitriser React de A à Z - Créer son propre NETFLIX'.

Demo on Heroku.

capture app

About

Concepts covered

- Decompose and prioritize main components

App

---Header

---Home page:

------Header Img

------Searchbar

------Posters List

---------Poster

------------Item

---------------Header

---------------HeaderDetails

---------------Stars

---------------Container

---------------Actor List

------------------Actor List

------Load Button / see more

- Decompose and prioritize Player Components

App

---Header

---MoviePlayer

------VideoPlayer

------MvPlayerList

---------MvPlayerListItem

- Decompose routing

App

---Header

---Details

------HeaderDetails

---------Container

---------Stars

------ActorList

---------Actors

- Decompose Redux

- State and Lifecycle of Components

Schema: components lifecycle

- Higher-order components (HOC)

Function that takes a component as parameter and that return another component

- When to use states

  • Does the data come(s) from a parent component with props?
  • Does it stays unchanged during process?
  • Can it be calculated using another state or props from the component?

=> 3xNO -> usually use states

=> identify in which component(s) the states have to 'live'

- Why use React.Fragment

<React.Fragment></React.Fragment> or <></>: used if we do not begin with html or if we use invalid DOM in JSX: "Fragments let you group a list of children without adding extra nodes to the DOM."

- Inverted data flow

Send data From children component to parent (ex: SearchBar, LoadingButton).

- React Router (Route, Link, Switch)

When you need to navigate through a React application with multiple views, you’ll need a router to manage the URLs. React Router takes care of that, keeping your application UI and the URL in sync.

- Redux

A Predictable State Container for JS Apps.

redux schema

See my watch about Redux

Playground to test the following exemple

Exemple

//Initial state
const initialState = {
  "name": "Vincent",
  "age": 42
}

//REDUCER (state, action)
//Pure: always return a new state
//We use one reducer, but we can use several reducers if needed

const reducer = (state = initialState, action) => {
  //If an action is dispatched
  if(action.type === "INCREMENT_AGE"){
    return {
      "name": state.name,
      "age": state.age + action.payload //payload = data emited
    }
  }
  if(action.type === "CHANGE_NAME"){
    return {
      "name": action.payload,
      "age": state.age
    }
  }
  //Return the new state to the store
  return state;
}

//STORE
//There is only one store
const store = Redux.createStore(reducer);

//Value of global state
store.getState()
// => {"name":"Vincent","age":42}

//ACTION CREATORS
//Functions that take arguments and return an action.

//Action 1 (it will display the state again)
const action1 = {
 type: "INCREMENT_AGE", //type is mandatory
 payload: 3 //properties can have any name
}
// => {"name":"Vincent","age":42}

//Dispatch action1 to reducer
store.dispatch(action1);
// => "type":"INCREMENT_AGE","payload":3}

//New state
//Value of new state in the store
store.getState();
// => {"name":"Vincent","age":45}

//Action 2 (it will display the state again)
const action2 = {
  type: "CHANGE_NAME",
  payload: "Daniel"
}
// => {"name":"Vincent","age":45}

//Dispatch action2 to reducer
store.dispatch(action2)
// => {"type":"CHANGE_NAME","payload":"Daniel"}

//New state
//Value of new state in the store
store.getState();
// => {"name":"Daniel","age":45}

- Redux: Connect

Higher-order component, connect components to Redux.

connect (A, B)(Component)

  • A: function mapStateToProps, is used for selecting the part of the data from the store that the connected component needs.
  • B: function mapDispatchToProps, is used for dispatching actions to the store.

redux-inspector capture

How to use

Localy

Clone,

Then:

npm install
npm start

Open the app using http://localhost:3000/

Build test:

npm install -g serve
serve -s build

Open the app using http://localhost:5000/

Warning: you have to rename _config.js by config.js and provide your own key for API TMDB

Online

See demo on GitHub page.

Packages used

Useful links

About

React - Redux - Firebase: Master React from A to Z - Create your own NETFLIX. (Demo on Heroku)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published