Skip to content

Batching update in react-hooks #2

@timtnleeProject

Description

@timtnleeProject

Reference: facebook/react#14259

Any state updates triggered inside that callback will be batched. Any state updates triggered outside that callback will not be batched. Timeouts, promises, and async functions will end up executing outside that callback, and therefore not be batched.

Update states multiple times like

setA('a');
setB('b');

within async function like api callback, timer etc...
will not batch updated

We can use useReducer to avoid redundant rendering calls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions