Skip to content

Are actions part of the state? #2813

Answered by dai-shi
alexgleason asked this question in Q&A
Discussion options

You must be logged in to vote

I can understand that and propose this:

title: Practice with no store actions

But, in general people like store (state) actions.

I think one reason is that it's the same idea with useState. People are very used to this pattern:

const useCount = () => {
  const [count, setCount] = useState(0);
  return {
    count,
    inc: () => setCount((prev) => prev + 1),
  };
};

Maybe, some middleware that prevent overwriting state functions might be possible.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@alexgleason
Comment options

Answer selected by alexgleason
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants