thomasprandall / kid-kreator

0 stars 0 forks source link

Should kid changes be done with useReducer? #3

Open thomasprandall opened 2 years ago

thomasprandall commented 2 years ago

Context and useReducer is leading to way more component re-renders than we really need. There isn't any noticeable performance dip right now but this should be refactored to use a state manager. That way we can easily reference kid data without updating as many components when a single value is changed. I am thinking I will try this in two branches, one with Redux and one with Zustand to see which I prefer.

Bonus points is we may be able to add Undo/Redo buttons after state management is updated.

thomasprandall commented 2 years ago

Working on a proof of concept for implementing Zustand and one of the cool things is I can use their persist middleware to essentially do everything I am doing to keep the data in localStorage. So that is neat. The zustand branch of this will basically be a complete rewrite except for the UI markup

thomasprandall commented 1 year ago

Zustand branch has issue where deleting the "last" kid in the kids array deletes the entire state instead of just that array index. Other kids are deleted correctly.