Giter Site home page Giter Site logo

reactjs-redux-basics's Issues

Please explain more about use case of redux thunk

The Tutorial: https://www.youtube.com/watch?v=h892pHdLQtM&list=PL55RiY5tL51rrC3sh8qLiYHqUV3twEYU_&index=10

At this moment: 4:59, we have below source code:


export function setName(name) {. 

	return dispatch => {. 

		setTimeout(() => {. 

			dispatch({. 

				type: "SET_NAME",  

				payload: name. 

			});  

		}, 2000);  

	};

}

Totally, we will have 3 dispatch functions:

  • 1 dispatch within file App.js
  • 2 dispatch within function setName within file actions/userActions.js

So, the first one (the one within App.js) is obvious, the executor is App.js

But I could not understand how other 2 dispatch could be executed by whom (i.e what is the executor?), and at what moment? And how can it be executed (i.e which mechanism ).

According to the async example, I understand that we need to have setTimeout to similar an async request. But, why do we need “dispatch” to be nested within setTimeout of another “dispatch => {}”

Could you please share your insight on this ?

Using redux-promise-middleware but the state does not changed

I had followed this video:
https://www.youtube.com/watch?v=h892pHdLQtM&index=10&list=PL55RiY5tL51rrC3sh8qLiYHqUV3twEYU_

Until the sample code for "redux-promise-middleware", after I trigger button "Change the Username", state does not change the name displayed on web-browser.

  "dependencies": {
    "react": "^16.3",
    "react-dom": "^16.3",
    "react-redux": "^6.0.0",
    "redux-logger": "^3.0.6",
    "redux-promise-middleware": "^5.1.1",
    "redux-thunk": "^2.3.0"
  },

Here is the screen capture which is showing that after 2nd event dispatched, the name is still the same

image

What if parameter passed to action is not satisfying the condition to update state?

This is more like question then issue,

I was looking at dispatch(setName(name)) code, and I wonder what if I have if statement in action and the parameter passed to action is not satisfying the if statement so I don't want to update the state. What should my action return, does it have to return something, is it an empty object or something else, or I should move dispatch callback inside my action and call it only if its statement satisfied.

There's no Redux Code

Hi Max, thank you for your amazing video, just missing the redux part of the code in these files ;) could be great to follow the videos and directly test code

redux 5 syntax change

This project uses redux 3.7.2. If you are using a more recent version of redux (e.g. 5), syntax for applyMiddleware has changed from applyMiddleware(logger()) to applyMiddleware(logger).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.