score:1
Accepted answer
Issue
You are using Array.prototype.forEach
to try and render your state. .forEach
is a void return, however, so nothing is returned to be rendered.
Solution
Use Array.prototype.map
to map the users
state to JSX.
{
users.map((u, index) => (
<li key={index}>{u}</li>
))
}
Source: stackoverflow.com
Related Query
- useState not updating state object after fetching data from API endpoint
- React is not updating the UI after receiveing data from the API call (using hooks)
- Fetching data first time from API endpoint it return empty array, after that return array with real information
- React-Table not updating after data prop is changed from state
- React JS (Form Update Not Working) - How to set state immediately after getting data from API using mapDispatchToProps?
- State not applied as expected when fetching data from API
- React not updating state on fetching API data by hooks
- REACT - Set initial data in Formik Form after fetching from API
- Axios not updating state from API in function called on Click, but works on identical function on Component Mount in React
- List of child components not updating correctly when deleting object from state
- React setState not working after deleting data from state copy
- Updating react state after data is sent to api
- I get data from Api but when I try to set the value with useState it give me an empty object
- I am fetching some results from an api and setting it to state but when results arrive my component did not re-rendred
- useState not updating data when passing from parent function component using ref
- useState data:null after fetching API data and set to useState
- Cannot assign to read only property 'approved_by_customer_admin' of object '#<Object>' after updating the api data manually
- React redux frontend not fetching data from Django API with axios
- Data not getting displayed from fetching from an api
- useState updating state child array object not working
- React: Looping over an object to bind useState functions is not updating the state of my application
- Fetching from API and updating the state of React comp
- Render Cards after fetch data from api and create an object
- Redux toolkit state is not updating after API response
- Printing variable after fetching data from API gives empty and after that filled value is printed
- How to export a variable after fetching data from API in reactjs?
- How to display data after getting complete data from API endpoint in react native?
- State value is not updating after passing a new value from children component
- Table body not updating in react , when fetching data from firebase
- useState in react is not updating the state object
More Query from same tag
- Argument of type 'number[]' is not assignable to parameter of type 'SetStateAction<ICoord | undefined>'
- Bootstrap custom styled checkbox is triggering click event twice
- ReactJS: Multiple Sort in Table
- React Multiple Fetch Requests
- react-fontawesome not displaying icons
- How do we use two themes on the same DOM element when using a ThemeProvider?
- React-query: Show loading spinner while fetching data
- Cypress type error when given string returned from cypress command
- Material-ui Grid Responsive Direction Column Width doesn't work
- Change the font size of the placeholder
- Unable to parse file when using webpack, react, react-dom
- How to add event listener to the div element accessed with ref using react and typescript?
- Update View After Sort Method Runs on Button Click
- Testing axios.create() instance with jest
- React - filter deletes all items instead of one
- How to format the text of the choices in a ReferenceInput field in react-admin?
- How does React make props read only?
- Issue using array of objects from API as JSON for d3 visualization
- Is there any way to dynamically add JSON fields in Javascript?
- How to create a modified useSelector custom hook with TypeScript
- how can i add new row my react bootstrap table
- Accessing similar DOM elements
- convert select component in material ui from fuction to class
- setState in none React component in a seperate file
- What's the best way to prevent React app being scraped?
- Enzyme cannot find child component
- Checkboxes checked by default
- react-google-maps Multiple markers and Info Window
- React Cannot read property 'setState' of undefined
- class doesn't get compiled by babel (nextjs / webpack)