Skip to content

Conversation

@t49tran
Copy link
Contributor

@t49tran t49tran commented Jun 7, 2018

This PR resolve the issue with <Input>, <TextField> and <TextArea> components don't accept React.createRef as inputRef or textareaRef.

Issues raised in #11709 #11486.

The idea for the solution is partly from #11293 and #11486.

Closes #11709

@oliviertassinari oliviertassinari changed the title Feat/allow React.createRef as [Input], [Textarea] inputRef and textareaRef [core] Add React.createRef support Jun 7, 2018
@oliviertassinari oliviertassinari self-assigned this Jun 7, 2018
@oliviertassinari oliviertassinari added type: new feature Expand the scope of the product to solve a new problem. core labels Jun 7, 2018
@oliviertassinari oliviertassinari force-pushed the feat/allow-createRef-input branch 3 times, most recently from 758ca0f to f3a3f6a Compare June 7, 2018 21:15
@oliviertassinari oliviertassinari force-pushed the feat/allow-createRef-input branch from f3a3f6a to f9bb9ec Compare June 7, 2018 21:33
@oliviertassinari oliviertassinari merged commit 30edbc8 into mui:master Jun 7, 2018
@oliviertassinari
Copy link
Member

@t49tran Thank you!

rows?: string | number;
rowsMax?: string | number;
textareaRef?: React.Ref<any>;
textareaRef?: React.Ref<any> | React.RefObject<any>;
Copy link
Contributor

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>;
Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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.

Copy link
Contributor

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! 😄

acroyear pushed a commit to acroyear/material-ui that referenced this pull request Jul 14, 2018
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: new feature Expand the scope of the product to solve a new problem. typescript

3 participants