Which state management tool should I use for a large global object?
Pretty much title. I tried asking in the beginner's thread but didn't get any takers unfortunately...anyway, if you can help, I'm basically making something like a D&D character creator SPA where multiple characters are stored and switchable between at any time. So my plan was to have several objects, one for each character, and nested inside those would be deeply nested objects containing the character stats, info, etc. E.g. something like this, but with a lot more fields & nesting:
const character = {
stats: {
strength: 20,
dexterity: 32,
...
},
abilities: [
{
type: "type1",
effects: {
physical: "Something physical",
mental: "Something mental"
}
}
]
}
I would use react context (perhaps using rambda lenses to edit the nested fields), but as far as I can tell it's not meant for state that updates a lot, since I think it causes everything in its tree to re-render? (Not 100% on that though) And as for other state libraries, I was considering zustand but I'm worried it's not meant for my use case of having monolithic objects, since I imagine that makes it hard to tell which components should be re-rendered on a change, which would then kinda defeat the point.
If you have any ideas, please let me know!
TL;DR: which state management tool do I use for an app with lots of regularly changing input fields that edit a nested global object?
Edit: Thanks for all the responses! But I suppose I should have also asked "and why?"
Posted Feb 8, 2022, 2:24 AM UTC · edited
Redux.