34
loading...
This website collects cookies to deliver better user experience
artist IDs
in my song display app. The only problem was that I was trying to use React-bootstrap-styled input boxes, and that cause significantly more confusion than it probably should have. More on this later.InputGroup
from React-bootstrap's documentation. Being how I am, I decided to copy-paste this code and immediately jump into trying to use it to figure out its quirks. id
"basic-addon1"
, because that's the ID of the InputGroup's Text! Wrong, it's just a decorator that is showing an @
before the text box. What else can it be?aria-label
and aria-describedby
hoping to be able to use them to reference the input
value. My conclusion on the aria
values is that you may be able to use them to access the text input, but it really seemed like overkill for the scope of my project. Next I attempted using ref
and inputRef
to access the input values. Again, I ran into a lot of trouble implementing any sort of way to access the data, even though I found a bunch of Stackoverflow answers. inputRef
instead of ref
to access the data, others would say to use ref
instead of inputRef
. Many answers seemed sure that you should create a new component class to contain the InputGroup
and FormControl
, however it felt like a very odd way to handle accessing the input. Why would you import an InputGroup
component into another component, just to get the value of the text?getElementById
and I nearly facepalmed. getElementById
was one of the very first things I learned about in React, I used it to retrieve data being sent up from my Python Flask server.onChange
. In 10 minutes of learning about basics,I learned two solutions to a problem that I had spent the better part of an hour trying to solve.onChange={(e)=>...}
to retrieve the text every time it changes, or I can simply set id="uniqueId"
and retrieve it elsewhere using `document.getElementById("uniqueId").value. className
instead of class
) and other interactions I'm not quite used to yet. I imagine it will make more sense once I try it out more.