score:1
Accepted answer
Use index to pick the data you want
In this case you will need to find the last index. this is data.length - 1
Then you can get the very last data by simply going data[data.length - 1]
let datas = (this.state.data && this.state.data.length) && this.state.data[this.state.data.length - 1];
return datas ? (
<div className="box">
<div>
< Col sm="12" key={datas.id}>
<div key="a">
<CardText className="textForAdminPageButHereIsForRandomId">{datas.randomID}
</CardText>
</div>
</Col>
</div>
</div>) : null;
Source: stackoverflow.com
Related Query
- React Leaflet: Get objects from MongoDB to Leaflet map as markers (using node.js and express)
- React leaflet map get corners lat and long
- How to get map properties and handle events in leaflet v3 with react + redux?
- is there any way to get the location name from the longitude and latitude positions in react js google map
- Get and Map react Js
- React - get data from API and show in return using MAP function
- Is there a way to map over an array of objects in react and also get the accosiated images from cloudinary
- How to render react components by using map and join?
- Get object data and target element from onClick event in react js
- How to get country code and Country name using IP in react js
- Trying to get then send a cookie using react and fetch
- Leaflet React get map instance in functional component
- how to access vairables outside of map function in js and jsx in a React component
- React and Socket.io: Able to get initial data - but view doesn't update when a new post comes in
- Get size of array returned by map in React render
- react - how do I get the size of a component child elements and reposition them
- How do I use React and forms to get an array of checked checkbox values?
- React fetch, “credentials: include”, breaks my entire request and I get an error
- Unable to get onDragStart Event on React for HTML5 Drag and Drop
- In Visual Studio 2012, I get warnings and squiggly lines when trying to write JSX with React JS
- React and Axios GET request issue with Safari on MacOs and iOs
- react if statement in jsx and map
- Get key and item onPress TouchableOpacity when items are map
- How do I get acces to only one item from map method in react js
- Using a hook in react to change boolean and get a callback
- React Context : Get Data from API and call API whenever some events happens in React Component
- Get Message From Kafka, send to Rsocket and Receive it from React client
- React router base code-splitting (get first chunk and then get other chunks async in background)
- How to get image height and width from uri on React Native?
- react router 4 and express : cannot GET
More Query from same tag
- How to render/map through an array of objects in React
- How to make AppBar component from material-ui-next react to scroll events
- Error when using or operator in a function argument type
- How to handle pagination in react table?
- Notify child components of transition state in TransitionGroup
- Firebase RTDB - Get document ID?
- React Router v6 - nested routing without Outlet
- Working with component state or props inside Redux mapDispatchToProps
- Dropdown with input field
- React Render HTML object from JSON object
- React/Flux way to handle permission sensitive actions with login flows
- Ternary inside input react
- Const being treated as string React.JS / fetch
- Unable to update state hook on keyDown
- Nodejs async loop is blocking React UI render
- React+JavaScript: How to erase data fields after a successful 200 code from sign up page and redirect to login?
- I want to use axios with foreach in useEffect react Js but it gives me (cannot read property Symbol(Symbol.iterator) error?
- How can i test a component with setProps() of enzyme
- Styled components onClick rotate element
- React - not refresh page after post with error response
- Authenticating to Asp.Net core 2.0 MVC application (cookie) and REST API (JWT) simultaneously
- React update checkbox from object value
- React modules installation fails
- Does props.history.listen in React Router need to be cleaned up in useEffect? If so, what is the right way to do it?
- How can a wrap a setValue call from the React useState hook and maintain the same type signature?
- Filter array of objects through checkboxes
- updating states in a object of local state in react js
- antd dropdown is not closing on mouse leave
- React: Cannot set property 'lastEffect' of null
- Redirecting a user to the page they requested after successful authentication with react-router-dom