Skip to content

fix: Make props optional in rerender function returned from renderHookToSnapshotStream #14

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

Merged
merged 5 commits into from
Jan 16, 2025

Conversation

jerelmiller
Copy link
Collaborator

Fixes #13

Makes the props argument optional in the rerender function returned from renderHookToSnapshotStream. This aligns it with RTL's rerender function returned from renderHook.

@jerelmiller jerelmiller requested a review from phryneas January 13, 2025 20:40
@jerelmiller jerelmiller changed the title Make props optional in rerender function returned from renderHookToSnapshotStream fix: Make props optional in rerender function returned from renderHookToSnapshotStream Jan 13, 2025
@jerelmiller jerelmiller force-pushed the jerel/fix-non-optional-props branch 2 times, most recently from af16f41 to f7b9229 Compare January 13, 2025 20:47
Copy link

pkg-pr-new bot commented Jan 13, 2025

yarn@berry undefined https://pkg.pr.new/testing-library/react-render-stream-testing-library/@testing-library/react-render-stream@14

commit: ac0b317

@jerelmiller jerelmiller force-pushed the jerel/fix-non-optional-props branch from f7b9229 to 0167414 Compare January 13, 2025 20:52
: Arg
: Arg

export async function renderHookToSnapshotStream<ReturnValue, Props = void>(
Copy link
Member

Choose a reason for hiding this comment

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

We can actually reach the same result, but more situational and "correct" by defaulting Props to void instead of the default unknown.

This way if you have an actual argument defined for the function, it will stay required, but if there is no argument it will be void, making it optional.

We do need a little bit more work to also correctly work if the function argument is optional from the start - the VoidOptionalArg takes care of that.

Copy link
Member

@phryneas phryneas left a comment

Choose a reason for hiding this comment

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

I never really liked it that rerender was so loose, so I think this could solve it more correctly. Could you please give this a re-review from your side @jerelmiller?

If you're happy with this, merge the branch and it will immediately be released.

@jerelmiller
Copy link
Collaborator Author

@phryneas I would agree, I like the idea of making it optional only if its truly optional. RTL ended up changing my mind, but happy to go this route for this package. Thanks for the assist!

@jerelmiller jerelmiller merged commit 6003495 into main Jan 16, 2025
8 checks passed
@jerelmiller jerelmiller deleted the jerel/fix-non-optional-props branch January 16, 2025 15:47
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.

rerender function returned from renderHookToSnapshotStream requires a props argument even when its optional
2 participants