const [valueState,setValueState] = useState("")
// create a function that handle the React-select event and
// save the value of that event on an state every time the component change
const handler = (event) => {
const value = event.value
setValueState(value)
}
<Select options={"your options"} onChange={handler}/>
const [data, setData] = useState({
name: "",
});
const handleData = (name, value) => {
setData({
...data,
[name]: value,
});
};
onChange={(e) => handleData("name", e.target.value)}
import React, { Component } from 'react';
import './App.css';
import Header from './Header';
class App extends Component {
constructor(props) {
super(props);
this.state = {name: "Michael"}
}
changeTitle = (e) =>{
this.setState({name: e.target.value});
}
render() {
return (
<div className="App">
<Header title={this.state.name}/>
<p className="App-intro">
Type here to change name.
<input type="text" onChange={this.changeTitle}/>
</p>
</div>
);
}
}
export default App;