0

I have an input whose value I want to store in a React variable.

<div>
  <label>Nombre Completo: </label>
  <input style={eachBit} required id='name' type='text' placeholder='Zeus Aurel'></input>
</div>

Without the complications of constructor or classes, I can't find anything useful anywhere. I know nothing of reactjs, please help.

vijayst
  • 20,359
  • 18
  • 69
  • 113
Dan
  • 160
  • 1
  • 6
  • 19
  • Do you have some code that you're working on? Otherwise I'd have to say learn react before trying to do something in react – Aswin Ramakrishnan Sep 18 '18 at 04:05
  • Possible duplicate of [Storing data in React](https://stackoverflow.com/questions/48356854/storing-data-in-react) – vijayst Sep 18 '18 at 04:08

2 Answers2

0

onChange event allows value to be stored in state. Here is how input value is stored in a state named inputValue.

<input 
  onChange={e => this.setState({ inputValue: e.target.value })) 
/>
vijayst
  • 20,359
  • 18
  • 69
  • 113
0

Are you asking about the way to change/insert a HTML element as a variable ?

Hope this topic can help you : Insert HTML with React Variable Statements (JSX)

Harley Liang
  • 92
  • 10