1class Example extends React.Component {
2 constructor(props) {
3 super(props);
4 this.state = {
5 count: 0
6 };
7 }
8
9 render() {
10 return (
11 <div>
12 <p>You clicked {this.state.count} times</p>
13 <button onClick={() => this.setState({ count: this.state.count + 1 })}>
14 Click me
15 </button>
16 </div>
17 );
18 }
19}
1Redux is overused. Don't use it.
2
3Props, Component composition and useContext/useReducer is enough for 95% of the apps.
1Modern State management in React:
2
3Demo:
4
51. Component composition:
6 https://codesandbox.io/s/4gyw5
7 https://codesandbox.io/s/p98n45z1wq
8
92. Props:
10 https://codesandbox.io/s/vmr357j2z3
11 https://codesandbox.io/s/j35ok11j13
12
133. useContext + useReducer
14 https://codesandbox.io/s/m4r124zkpj
15
16
17
18
19Expanded from user Pleasent petrel's advice to use these tools instead of Redux
20https://www.codegrepper.com/app/profile.php?id=106359