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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: can't pass ref as a props for Input component #1839

Closed
kouji-dev opened this issue Sep 21, 2020 · 3 comments 路 Fixed by #1853
Closed

fix: can't pass ref as a props for Input component #1839

kouji-dev opened this issue Sep 21, 2020 · 3 comments 路 Fixed by #1853
Labels
bug Something isn't working typescript

Comments

@kouji-dev
Copy link

kouji-dev commented Sep 21, 2020

Hello, I have an issue adding additional props for the input, for example when trying to bind ref prop to the component

##Screenshots
image

To Reproduce 馃暪

Just try to attach a ref prop to the Input component

Context 馃敠

I'm using react-rainbow in a type-safe system (typescript) with react-hook-form and apparently ref is not allowed on the Input props so I can't bind their hooks with your component.

Suggestion

I think a quick fix would be to add an optional property to the BaseProps interface

interface BaseProps {
className?: string;
style?: CSSProperties;
ref?: any;
}

Or a more sophisticated :

interface BaseProps {
className?: string;
style?: CSSProperties;
ref?: T;
}

@kouji-dev kouji-dev added the bug Something isn't working label Sep 21, 2020
@LeandroTorresSicilia
Copy link
Member

LeandroTorresSicilia commented Sep 24, 2020

Hi @goodbeysr, you are right we need to define the ref type in the typescript declaration file of the component.
I think we should use a more specific type like MutableRefObject which is what React.useRef returns or a more generic Ref<any>.
I will make a PR request fixing this for the Input, we need to also make this for other components.
Thank you for the feedback and it is great that you are using react-rainbow.

@LeandroTorresSicilia
Copy link
Member

what we will do is to add ref in base props as you showed in the description then all component will have the ref defined

@TahimiLeonBravo
Copy link
Collaborator

TahimiLeonBravo commented Sep 24, 2020

@goodbeysr the issue has already been fixed and will be available in the new version 1.18.0 of react-rainbow-components

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants