mschwarzmueller / reactjs-redux-basics Goto Github PK
View Code? Open in Web Editor NEWSource Code of my ReactJS Redux Basics Series on YouTube
License: MIT License
Source Code of my ReactJS Redux Basics Series on YouTube
License: MIT License
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:
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 ?
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
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.
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
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)
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.