Skip to content

A React functional component hook to mimic Class component object state management.

Notifications You must be signed in to change notification settings

quangdng/useStateObject

Repository files navigation

useStateObject hook

Build Status codecov npm

A React functional component hook to mimic Class component object state management.

Examples:

State declaration:

const [state, setState] = useStateObject({
  isLoading: false,
  isError: false
});

Usage:

// State will be merged with the object you provide to setState instead of being replaced
setState({
  isLoading: true
});

// State is now
// {
//    isLoading: true,
//    isError: false
// }

About

A React functional component hook to mimic Class component object state management.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published