I am adding the reference to this blog, https://medium.com/javascript-in-plain-english/testing-react-hooks-be74ec3fc0c4, only because the author used a gif of 'Indiana Jones' which is a cool way of explaining a mock function. I haven't read the article yet.
More to come here...
Saturday, May 16, 2020
Sunday, May 3, 2020
React Redux Example
Basics:
- Redux provides means to create an empty store where application state can be manufactured.
- You tell the store what to create as the application state, how to update the application state thru reducer.
- Reading from the application state in application is straight forward.
- Updating the application state is by triggering the update logic in the store by dispatching the actions.
- NOTE: When you update a state, you don’t update the state but rather create a new state out of old state.
- react-redux provides couple of additional facilities, Provider and connect.
- Provider to provide the store to the root component.
- Connect passes state, dispatch actions to child component.
Example:
- npx create-react-app reduxexample
- cd reduxexample
- npm install redux
- npm install react-redux
- Remove all files under src folder and public folder
- Create index.html under public folder
- Create rest of the files under src folder
- npm start
index.html
index.js
reducer.js
dispatcher.js
kitchen.jsx
Menu.jsx
App.jsx
Subscribe to:
Posts (Atom)