Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update Zustand, resolve deprecated imports #3423

Merged
merged 4 commits into from
Jul 15, 2024
Merged

Conversation

DafyddLlyr
Copy link
Contributor

@DafyddLlyr DafyddLlyr commented Jul 12, 2024

What does this PR do?

  • Update Zustand from 4.3.8 → 4.5.4
  • Resolve deprecation warning about zustand/vanilla (see below)
image

Motivation

  • Zustand's persist middleware may be a nice way of handling our local storage capacity issues (switching to indexdb?)
  • This would also allow us to rationalise up some of the logic around session storage here -

if (isUsingLocalStorage) {
const state = getLocalFlow(id);
if (state) resumeSession(state);
createAnalytics(state ? "resume" : "init");
setGotFlow(true);
} else {
NEW.getLocalFlow(sessionId).then((state) => {
// session data is resumed by ./ResumePage.tsx
createAnalytics(state ? "resume" : "init");
setGotFlow(true);
});
}
}, []);

  • Seems worthwhile to get things in ship-shape before looking into this
  • The warning's been bugging me for ages! 😅

Copy link

github-actions bot commented Jul 12, 2024

Removed vultr server and associated DNS entries

Comment on lines -57 to -62
interface PlanXStores {
// Non-React implementation (e.g. for use in tests)
vanillaStore: StoreApi<FullStore>;
// React hook
useStore: UseBoundStore<StoreApi<FullStore>>;
}
Copy link
Contributor Author

@DafyddLlyr DafyddLlyr Jul 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zustand no longer requires the use of a vanilla store outside of React components.

This means we can use the useStore() hook in React components, and useStore.getState() elsewhere consistently.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice simplification!

@DafyddLlyr DafyddLlyr requested a review from a team July 15, 2024 06:23
@DafyddLlyr DafyddLlyr marked this pull request as ready for review July 15, 2024 06:23
@DafyddLlyr DafyddLlyr merged commit d8a990e into main Jul 15, 2024
12 checks passed
@DafyddLlyr DafyddLlyr deleted the dp/update-zustand branch July 15, 2024 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants