score:1
Accepted answer
data
is an object rather than an array so calling map
on it triggers an error.
simply do this.state.data.segments.map(...)
instead, and change your initial state to
state = { data: { segments: [] } }
score:0
map
is a function of array
. the data
is an object while data.segments
is an array. you will need to change the code as below
<div classname="clientcontainer">
{
this.state.data.segments.map( item =>( //change here
<div>
<span> {item.clientname} </span>
</div>
))
}
</div>
Source: stackoverflow.com
Related Query
- Issue in accessing API/json with multiple sections
- TSX React - How to index JSON API Data with multiple JSON Objects
- Getting issue with heremap multiple pickup and multiple drop api
- Multiple API Calls using Promise.all fine to show results in console but Issue with State
- Accessing a private JSON File with API key / secret key failing
- React.js: loading JSON data with Fetch API and props from object array
- CORS Issue with React app and Laravel API
- Unexpected end of JSON on GraphQL query with React while no issue with GraphiQL
- Issue using multiple styles with Material-ui and Radium
- How to map API with multiple objects [Spree API V2 & ReactJS]
- Accessing internal API with React, Axios on Heroku
- Accessing global variables in Sass with Webpack without multiple imports
- How to make a POST request with json content type with Semantic UI API
- Testing recompose with enzyme - accessing props issue
- Accessing data from rest api with reactjs
- CORS issue when trying to do JQuery post with json data, but not with plain text or x-www-form-urlencoded
- Multiple API calls with fetch in chain and Promise.all
- Query multiple JSON files with graphQL in Gatsby
- How to implement multiple api call in a single query with RTK query
- React with Redux Axios get request error issue with laravel 5.2 api server
- Using multiple CSS rule names with the styled API in Material UI
- Accessing multiple arrays of data with different numbers
- How to download single file with multiple chunks in javascript using fetch API
- Cannot get access token in React app accessing protected .NET Core API with Azure B2C
- How to use map function with JSON object fetch though an API
- Pagination with React from JSON data issue
- Structuring and retrieving JSON object (an image) with multiple sizes
- issue with sending headers in post request to the API
- Issue Fetching API Data with React.JS
- Json API access error with React
More Query from same tag
- Newbie question: How do I properly factor code in a simple form handler w/ React and Apollo client
- Deploy a package to different projects
- How to have multi line options in a select Material UI
- How to clear the input field (remove the search term) after the search?
- Deploy React + Spring Boot JAR within service/process to AWS EC2 Linux Server
- Any Proper/Clean way to handle a Large number of if..then case in react table?
- Debounce input does not read keyboard information
- Can't customize background of a Tooltip popup?
- Docker Create react app hot reload not working
- CORS errors when trying to fetch from new Google Cloud API Gateway
- How to add props to state
- How to import image from external folders in react
- React JS To do list app | Get value and push to state
- What is the suitable type for renderHook in react-testing-library and TypeScript?
- Why componentWillReceiveProps is not called?
- I want to call a certain parameter from my api
- React state not updating when looping through array
- React Router Redux always show first route
- React Router v4 not rendering parent components
- How to display and hide elements correctly in Reactjs
- Webpack does not look for changes in SCSS
- Jest parametrized test - if condition inside
- how to do a button who open a popup
- How to use PrimeReact's Button component?
- Jest : TypeError: require(...) is not a function
- How to dry up type definition of function that returns another function
- Delete the entire div including subdiv's on clicking the remove button
- How can I conditionally add Javascript component current date?
- React Native - Why do I need babel or webpack?
- How to fix Filtering (map) on React