-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
[core] Add React.createRef support #11757
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
[core] Add React.createRef support #11757
Conversation
758ca0f
to
f3a3f6a
Compare
f3a3f6a
to
f9bb9ec
Compare
@t49tran Thank you! |
@@ -11,7 +11,7 @@ export interface TextareaProps | |||
disabled?: boolean; | |||
rows?: string | number; | |||
rowsMax?: string | number; | |||
textareaRef?: React.Ref<any>; | |||
textareaRef?: React.Ref<any> | React.RefObject<any>; |
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.
This is not needed. React.Ref<>
includes React.RefObject<>
type Ref<T> = string | { bivarianceHack(instance: T | null): any }["bivarianceHack"] | RefObject<T>;
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.
You are right, feel free to make another PR to remove 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.
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.
React.Ref<any> | React.RefObject<any>
can also be found in couple of other places, do you want to work on it @franklixuefei ? Otherwise I can make a PR to replace them.
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.
@t49tran Sorry I was busy working on something else lately. Please go ahead! Thanks! 😄
* feat: make input accept both ref callback and ref from React.createRef * feat: update [TextArea] to accept React.createRef object as inputRef * feat: update typescript and proptypes declaration for inputRef * test: add inputRef test for input * simpler logic
This PR resolve the issue with
<Input>
,<TextField>
and<TextArea>
components don't acceptReact.createRef
asinputRef
ortextareaRef
.Issues raised in #11709 #11486.
The idea for the solution is partly from #11293 and #11486.
Closes #11709