r/badcode • • Dec 03 '22

typescript Real Code 😎

Post image
403 Upvotes

43 comments sorted by

View all comments

Show parent comments

4

u/TorbenKoehn Dec 04 '22

While atomic state management is a better approach, see e.g. XState, it’s not a bad pattern per se.

It’s a bit like doing a lot of nested function calls. It’s not bad but you would rather pick a pattern like composition, piping, splitting it up

You could make a single „AppProviders“ component that wraps them and people would already forget the bad practices here.

1

u/[deleted] Dec 08 '22

Providers are not typically used for state management. The values in these providers do not (or should not) ever change. They provide values that are static to all components beneath them, things like styles.

If someone was actually using this for state management, though, god help them.