react-semantify icon indicating copy to clipboard operation
react-semantify copied to clipboard

Refs on inputs

Open tomitrescak opened this issue 9 years ago • 3 comments

Thanks for this wonderful package. I have a question concerning handling of refs on form elements. How can I approach this? I need a value from the input control. Thanks!

tomitrescak avatar Apr 23 '16 10:04 tomitrescak

Use react ref to reference your <input /> element? ex. https://facebook.github.io/react/docs/more-about-refs.html#the-ref-string-attribute

jessy1092 avatar May 01 '16 06:05 jessy1092

Hmm, that much I know ... since I'm talking about wanting to use refs ;) The problem is that you render input INSIDE your Input control, therefore the ref belongs to the Input control, not the parent containing control. So I simply cannot access the ref'd component.

tomitrescak avatar May 01 '16 11:05 tomitrescak

@tomitrescak OK, I see. Sorry, I misunderstand. You could add custom <input /> element as the <Input />'s children and it would render custom <input /> inside. :) Then you could add ref by yourself.

like:

<Input>
 <input placeholder="Search..." type="text" />
</Input>

It would become

<div class="ui input">
  <input placeholder="Search..." type="text" />
</div>

PS. If you do this, placeholder and type would be not working.

jessy1092 avatar May 01 '16 12:05 jessy1092