-
Notifications
You must be signed in to change notification settings - Fork 294
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: expose setHistories and setHistoryIndex #525
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@mkilpatrick is attempting to deploy a commit to the Measured Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff again! Left a few comments.
Co-authored-by: Chris Villa <chrisvxd@users.noreply.github.com>
Co-authored-by: Chris Villa <chrisvxd@users.noreply.github.com>
Co-authored-by: Chris Villa <chrisvxd@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bravo
act(() => renderedHook.result.current.record("Oranges")); | ||
act(() => renderedHook.result.current.setHistoryIndex(0)); | ||
|
||
expect(renderedHook.result.current.hasPast).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to full remember the functionality of hasPast
.
This test (and some of the ones I wrote) read to me like hasPast
should be false
when you're at index 0
, but they're all asserting it to be true
.
This is nothing wrong with your tests, but just making a note for myself to think about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-1 is the no history index
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.