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

Expose setHistories and setHistoryIndex #519

Open
mkilpatrick opened this issue Jun 25, 2024 · 0 comments
Open

Expose setHistories and setHistoryIndex #519

mkilpatrick opened this issue Jun 25, 2024 · 0 comments

Comments

@mkilpatrick
Copy link
Contributor

It would be nice to be able to reset the history so that Puck rerenders with the change. My use case is that I have a clear history button which wipes localStorage/our DB-saved history and I want Puck to also reset fresh with no history. There's currently no way to do that because setHistories() isn't exposed. I can only set initial and then hard refresh the page.

It's worth noting that even though my setup is causing Puck to rerender, it isn't remounted, so even though initialHistory is updated, the underlying histories aren't.

chrisvxd added a commit that referenced this issue Jul 23, 2024
This addresses #519.

This change exposes the history store's setHistories and setHistoryIndex
functions. When they are called the data is dispatched so that Puck
rerenders. The use case this supports is when a Puck consumer wants to
change or reset the history state manually without requiring the page to
be refreshed.

---------

Co-authored-by: Chris Villa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants