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
A store has three functions that you're going to be using in this course:
- getState - fetches the current state of a store
- dispatch - fires off a new action
- subscribe - fires a callback everytime there's a new action after a reducer's action
We'll have the App component subscribe to the state using one of React's life-cycle hooks called componentWillMount(). This function is called when the component is going to be rendered, so it's a good place to put initialization logic.
We subscribe to the redux store and call React's setState()
function
every time the store changes so we always get the newly reduced state. React calls the render()
function every time the
component's state changes, which "renders" the component.
setState
function
src/index.js
class App extends React.Component {
constructor() {
super();
this.state = {};
}
componentWillMount() {
store.subscribe(() => this.setState(store.getState()));
}
render() {
[...]
Let's tweak the App component to display a checkbox whose state depends on the redux store.
src/index.js
render() {
return (
<div>
<h1>To-dos</h1>
<div>
Learn Redux
<input
type="checkbox"
checked={!!this.state.checked}
/>
</div>
{
this.state.checked ? (<h2>Done!</h2>) : null
}
</div>
);
}
What happens when you click on the checkbox? Absolutely nothing! What gives? One of the key ideas of React is that what gets displayed is a pure function of the component's state. In other words, since your state doesn't change, React will always render the checkbox as checked.