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

Recommended way to access native elements #36

Open
piotr-cz opened this issue Aug 8, 2017 · 0 comments
Open

Recommended way to access native elements #36

piotr-cz opened this issue Aug 8, 2017 · 0 comments

Comments

@piotr-cz
Copy link

piotr-cz commented Aug 8, 2017

I'd like to use native Constraint validation and be able to call checkValidity and reportValidity methods on individual inputs.

For that I need to access native elements like input , textarea and so on.

Using a ref attribute on a react-mdc-web element doesn't work as it points to react-mdc-web component and ref attribute is not being passed further using { ...otherProps } (I recall this is a react constraint).

What about adding special attribute that will translate to ref on native element, like so:

<TextField
  nativeRef={ el => this.nativeInput = el }
/>

implementation in Textfield/Input.js could be

const Input = ({ multiline, nativeRef, ...otherProps }) => {
  const type = multiline ? 'textarea' : 'input';
  return createElement(type, { className: ROOT, ref: nativeRef, ...otherProps });
};
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

No branches or pull requests

1 participant