score:1
Accepted answer
Probably I would add default initial value to useState
as instead of ''
:
const [category, setCategory] = useState(categoryList[0]);
Or maybe if the data is coming dynamically then calling setCategory()
with the value from the API result what you would like to have as default.
I hope this helps!
Source: stackoverflow.com
Related Query
- How to set the default selected value while clicking on submit or very first time while loading - React Hook
- How to set the first value in a select dropdown to as a default react
- How do I set the result of an API call as the default value for a Recoil atom?
- How to set the default value to props
- How to set the default react context value as data from firestore?
- React - How do I display the first value of an array as the default value in a select form?
- How can I set the default state of a checkbox based on value in firestore in react table
- how to set the default value for the input from a db in React
- How to disable a submit button in redux form for the second time after the form is submitted for the first time?
- How to play a sound only at the first time false value after true
- Can value of input box be set to to empty string on clicking submit button when the input is in a stateless functional component?
- How to set the default value of a select option when mapping over array
- How can I set a default image if the image link value is null?
- How to prevent the submit button from reloading the page, while keeping default form warnings?
- how to push the form data into array while clicking the submit in reactjs
- start with the default state upon rendering the component for the first time ! where no mood has been selected yet
- How can we hold/persist the selected dropdown value after submit and reset the textarea in react hooks form
- How do I set the default value of a <select> element in React?
- How to click the card and while clicking the next button it will redirect based on selected card?
- ReactJs : How to have a default value selected in the RegionDropdown
- How to set the default value for input type number
- Set a selectbox default value just after the form submit
- How to change, using React, the value of a form input after clicking the submit button
- Why does React rerender when the state is set to the same value the first time via an onClick event on DOM, but not react-native?
- Auto submit a dropdown when a value is selected other than the first value?
- How to display on select the first group value selected first ? (with 2 different select)
- How to set a default value in react-select
- How to set default value in material-UI select box in react?
- React.js - How to set a default value for input date type
- How to do POST in FORM Submit using reactjs and pass the object value into REST service?
More Query from same tag
- How to get the value of DateRangePicker (syncfusion) on react js
- React state update on object
- Add Modal Component To Card component in React
- Set background in React.js using style
- React - await until data fetches from API
- Using a map within a map in jsx
- Convert Blob to image inside Cell in React
- reactjs, sending props from one component to another
- Check if property exists using React.js
- getStaticProps error on build with Contentful in Next.js
- What is "npm run build" in create-react-app?
- Reactjs custom hooks generates jsx and controls events
- How to change the style of an element when clicked in React
- Unable to play a different song using setState method in ReactJs
- How to send props value to styled component in emotion react?
- MUI Autocomplete Typescript: What is the type of PaperComponents function parameter
- How to pass the content of your columns to a dummyField in react-bootstrap-table2
- ReactJS How to use Router's props inside app.js file
- add dynamic empty objects to an array React
- Fetching multiple objects at the same time in react
- How to wrap array of html span tags with more span tags?
- How to dynamically change SVG fill color?
- import Recharts.js library to jsx react file
- Tailwind CSS animations not working in ReactJs/NextJs
- How to add Apply button to bottom of AntD Date ranger Picker, to run an API call?
- How to conditionally color specific rows in an AntD table
- Module '"<file path>/react-redux"' has no exported member 'Dispatch'
- How to force React to use setState with only function?
- how to Open a modal inside of a response async?
- Mutate multiple states from within useEffect causes react-hooks/exhaustive-deps warning