React-Redux Flashcards
What is Redux?
Redux is a state management framework. There’s only 1 way of changing the ‘state’; through an action dispatch. Pros: predictable state, easier debugging.
What is React?
React is a front-end framework. React uses a virtual DOM to keep track of components.
- JSX - allows mixing html and javascript together
- components - reusability, modular
- Virtual DOM - renders select components, not entire page.
What are lifecycle methods?
https://engineering.musefind.com/react-lifecycle-methods-how-and-when-to-use-them-2111a1b692b1
Lifecycle methods are a series of methods inherent to every component cycle. (Birth to death). They allow you to hook into a component’s life cycle stage, and control what happens next.
Use cases of lifecycle methods:
1 ) componentWillMount
2) componentDidMount
“You can’t guarantee the AJAX request won’t resolve before the component mounts. If it did, that would mean that you’d be trying to setState on an unmounted component, which not only won’t work, but React will yell at you for. Doing AJAX in componentDidMount will guarantee that there’s a component to update”
Use cases: AJAX calls, setState
3) componentWillReceiveProps
“component receives props that was not directly passed down originally. It is not called on initial render”
A) Check which props will change
Use cases: componentDidMount AJAX calls, then sometime later the props being passed in changes
4) shouldComponentUpdate
“Called after componentWillReceiveProps. By default, returns true, but we can customize it. Function args (nextProps,nextState) –> changing props or setState called.
5) componentWillUpdate
6) componentDidUpdate
7) componentWillUnmount
What is Thunk?
Thunk is a redux middleware, and it allows you to delay the dispatch of an action. It allows dispatcher to handle functions as objects. Main purpose is for async actions.