'React.js - How to set a default value for date input type on react.js
I can't print the value of "dataSubEvento" in the input.
**const [dataSubEvento, setDataSubEvento] = useState(
props.activeSubEventData.data
);
<input
className="createsubevent-item_input"
onChange={(text) => setDataSubEvento(text.target.value)}
value={dataSubEvento}
type="date"
>
</input>**
Solution 1:[1]
You should make sure that your date format is yyyy-mm-dd in order to display the value, and to print the value you should use the useEffect hook, take a look at the complete example.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Yago Biermann |
