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: usePresenceSwitch cleanup #1

Merged
merged 2 commits into from
Feb 13, 2023

Conversation

amannn
Copy link
Collaborator

@amannn amannn commented Feb 10, 2023

Hey, here are some changes I'd propose to simplify and clean up the README a bit.

I'd also reduce the API surface to not handle null in a special way, maybe there's a use case where this is expected to be an actual value.

Let me know if this works for you!

getByTestId('none');
getByText('Nothing mounted');
rerender(<Expander text="initial value" />);
getByTestId('isAnimating, isEntering, isMounted');
getByText('initial value');
await waitFor(() => getByTestId('isVisible, isMounted'));
rerender(<Expander text={null} />);
rerender(<Expander text={undefined} />);
Copy link
Owner

Choose a reason for hiding this comment

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

I originally did this but the tests complained in a warning and told me to use null

mountedItem
};
}

function isNil<ItemType>(value: ItemType) {
return value == null;
function isUndefined<ItemType>(value: ItemType) {
Copy link
Owner

Choose a reason for hiding this comment

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

So I'm fine with this, but at this point, I feel like I lean towards just using item === undefined or item !== undefined in places rather than having the extra function 😅

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good!

@EthanStandel
Copy link
Owner

So feel free to merge this as you please, I just added a couple "food for thought" comments but it's nothing that affects the usability of the feature for me!

@amannn amannn merged commit 56bdd1c into EthanStandel:main Feb 13, 2023
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