react merge state

Using Object.assign() to create a copy of the object:

const items= Object.assign({}, this.state.items, item)
 this.setState({ items})

Using spread operator:

const items= { …this.state.items, item }
 this.setState({ items})



the doc is really not clear.

while truely, it turns out the debounce action needs to be PRE defined and evaluated.

so only the function is pre-defined like this will work

const preDefined = debounce((num)=> console.log("whatever action here", num), 100);
   [1, 2, 3, 4].forEach(num => {

"whatever action here"

while calling debounce() directly, simply like direct method calls

  [1, 2, 3, 4].forEach(num => {
    debounce(console.log("always defining", num), 100);

"always defining"
"always defining"
"always defining"
"always defining"

react render empty

according to react doc

Booleans, Null, and Undefined Are Ignored

falsenullundefined, and true are valid children. They simply don’t render. These JSX expressions will all render to the same thing:


class x extends Component{

good summary for react redux thunk


  1. There is 1 global state object that manages the state for your entire application. In this example, it will behave identically to our initial component’s state. It is the single source of truth.
  2. The only way to modify the state is through emitting an action, which is an object that describes what should change. Action Creators are the functions that are dispatched to emit a change – all they do is return an action.
  3. When an action is dispatched, a Reducer is the function that actually changes the state appropriate to that action – or returns the existing state if the action is not applicable to that reducer.
  4. Reducers are “pure functions”. They should not have any side-effects nor mutate the state — they must return a modified copy.
  5. Individual reducers are combined into a single rootReducer to create the discrete properties of the state.
  6. The Store is the thing that brings it all together: it represents the state by using the rootReducer, any middleware (Thunk in our case), and allows you to actually dispatch actions.
  7. For using Redux in React, the <Provider /> component wraps the entire application and passes the storedown to all children.