Next.js Discord

Discord Forum

Should i store deeply nested data in plain objects or a class?

Unanswered
Japanese common catfish posted this in #help-forum
Open in Discord
Japanese common catfishOP
So I find myself calling:
setCurrentWorkout(
                                            produce(currentWorkout, (draft) => {
                                                draft.name = e.currentTarget.value;
                                            }),
                                        )

all over the code base. So I was thinking whether I should create a class with methods like .setName so that I can simplify data manipulation.

7 Replies

Japanese common catfishOP
But i saw this answer: https://stackoverflow.com/a/71874663/11667450
and started debating whther this is the correct way to go?
@joulev try this then <https://jotai.org/docs/extensions/immer>
Japanese common catfishOP
im already using atomWithStorage so this wont be possible
Then I don’t know, sorry. I don’t use jotai.