Outline
- React/Redux Apps with Valeri Karpov
- Building Real World, Production Quality Apps with React & Redux
- Creating & Running React Projects With create-react-app
- Learn The Fundamentals of Redux
- Creating A Basic React-Redux Project
- Performing HTTP Requests with Custom Middleware
- Getting Started with React Router
- JWT Authentication with React & Redux
- Creating Forms with React & Redux
- CRUD Examples with React & Redux
- Utilizing Component Inheritance
- Implementing a Tabs Component with React & Redux
- Implementing Pagination with React & Redux
- Creating an Article Editor with React & Redux
Outline
- React/Redux Apps with Valeri Karpov
- Building Real World, Production Quality Apps with React & Redux
- Creating & Running React Projects With create-react-app
- Learn The Fundamentals of Redux
- Creating A Basic React-Redux Project
- Performing HTTP Requests with Custom Middleware
- Getting Started with React Router
- JWT Authentication with React & Redux
- Creating Forms with React & Redux
- CRUD Examples with React & Redux
- Utilizing Component Inheritance
- Implementing a Tabs Component with React & Redux
- Implementing Pagination with React & Redux
- Creating an Article Editor with React & Redux
To mutate(change) the redux state, you need to dispatch an action. Recall that an action is the 2nd parameter that gets passed to your reducer. An action is an object that tells your reducer what happened (e.g. toggle, click, etc.).
Let's create a function onClick
that calls the Redux store's dispatch()
function, which is how you fire off an action in Redux.
Dispatch the
TOGGLE
action when the checkbox is clicked
render() {
+ const onClick = () => store.dispatch({ type: 'TOGGLE' });
return (
<div>
<h1>To-dos</h1>
<div>
Learn Redux
<input
type="checkbox"
checked={!!this.state.checked}
+ onClick={onClick} />
</div>
{
this.state.checked ? (<h2>Done!</h2>) : null
}
</div>
);
}
Redux actions must have a type
property, so we created an action type TOGGLE
to match the reducer, and set the onClick
function as an onClick
handler
for the checkbox. You'll now be able to toggle the checkbox!
Check your work
You can view the completed & working code from this tutorial here: