How to use React.createRef() with Semantic UI React

Justyna Kuchta
The Startup
Published in
5 min readApr 14, 2020

--

Photo by Kevin Ku on Unsplash

Once upon a time, not long ago, I built my first React app. One of my components was a form the user is encouraged to fill out after they sign up.

This post was originally meant to give you a quick tutorial on how to create interactive forms in React with Refs. There are, however, many posts and tutorials out there that cover that subject. I am going to assume you know a little about refs and perhaps already used them in your components. I am here to help those of you who, like myself, used Semantic UI React to add style to their React app and suddenly realized adding a ref in a traditional way covered by the documentation returns null.

So anyway, here is what my code looked like:

myRef = createRef()...<Form.Inputref={this.myRef}id='first_name'label='First Name'placeholder='Enter your first name'/>

And here is what happened when I dropped a debugger in my render function to take a look at myRef:

--

--

Justyna Kuchta
The Startup

Web Developer based in Atlanta, GA. Book worm, cat lover, language geek. Open to new opportunities https://www.linkedin.com/in/justyna-kuchta-ab7b3b16/