Member-only story

Hookstate or Redux? Which one is the best state management tool?

Masoud Banimahd
3 min readJan 1, 2023

Hookstate is a state management library for React that allows you to manage your application's state using React hooks. In this article, we will explore how to use Hookstate in a React application.

First, you will need to install Hookstate by running the following command in your terminal:

npm install --save @hookstate/core

Next, you can create a Hookstate store by calling the useHookstate() hook and passing in an initial state:

import { useHookstate } from '@hookstate/core';

const state = useHookstate(0);

You can use the get() and set() methods of the store to access and update the store's value directly:

import React from 'react';
import { useHookstate } from '@hookstate/core';

export const ExampleComponent = () => {
const countStore = useHookstate(0);
return <>
<b>Counter value: {countStore.get()} </b>
<button onClick={() => countStore.set(p => p + 1)}>Increment</button>
</>
}

One of the key benefits of Hookstate is that it allows you to create multiple stores for different pieces of state in your application, and it makes it easy to access and update these stores from anywhere in your code. For example:

import { hookstate, useHookstate } from '@hookstate/core';

const countStore = hookstate(0);
const nameStore = hookstate('');

function Counter() {
const state = useHookstate(countStore)…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Masoud Banimahd
Masoud Banimahd

Written by Masoud Banimahd

Experienced Full-stack Engineer | NodeJS & .NET Pro | Tech Enthusiast | Knowledge Seeker - Reach me : https://masoudb.com/

Responses (1)

Write a response

This article provided is generally accurate and provides a good overview of the main differences between Hookstate and Redux.
Hookstate is indeed considered to be simpler and easier to use than Redux, as it does not require as much boilerplate code…