Skip to content

Add ref support to withTheme HOC #915

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
Aug 7, 2024

Conversation

sieu-db
Copy link
Collaborator

@sieu-db sieu-db commented Aug 7, 2024

Overview

  • Support forward ref for withtheme
  • Update example of BottomSheet try to use some BottomSheet method

Demo

Screen.Recording.2024-08-07.at.10.14.39.mov

@sieu-db sieu-db requested a review from YoussefHenna August 7, 2024 03:18
Copy link

linear bot commented Aug 7, 2024

Copy link

github-actions bot commented Aug 7, 2024

Published version: @draftbit/[email protected]

Copy link

github-actions bot commented Aug 7, 2024

Published version: @draftbit/[email protected]

YoussefHenna
YoussefHenna previously approved these changes Aug 7, 2024
};
) => {
return React.forwardRef(
(props: Omit<Props, "theme">, ref: React.Ref<any>) => {
Copy link
Collaborator

@YoussefHenna YoussefHenna Aug 7, 2024

Choose a reason for hiding this comment

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

With components that need a forwarded ref, I usually don't wrap them in a withTheme, instead I get the theme by using the useTheme hook and just export them as is. See the AudioPlayerWithInterface.tsx for example. By doing that, the type of the ref can be maintained and is not any like it is here. This works as well though, it'll just lose the type, but I'm fine with merging it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, adjust BottomSheet component

Copy link

github-actions bot commented Aug 7, 2024

Published version: @draftbit/[email protected]

@sieu-db sieu-db merged commit 57f189c into master Aug 7, 2024
3 checks passed
@sieu-db sieu-db deleted the sieu/p-3887-support-forward-ref-for-withtheme branch August 7, 2024 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants