score:1
Accepted answer
const IMGS = [
{
id: 0,
src:require("../img/a1.jpeg"),
},
{
id: 1,
src: require("../img/a1.jpeg"),
},
{
id: 2,
src:require("../img/a1.jpeg"),
},
{
id: 20,
src:require("../img/a1.jpeg"),
},
]
const imgFilter= IMGS.filter((img) => img.id >= 18 && img.id < 30)
{imgFilter.map(p => {
return <img key={p.id} src={p.src} />;
})}
score:1
Use filter
const IMGS = [
{
id: 0,
path: "../img/a1.jpeg",
},
{
id: 1,
path: "../img/a1-01.jpeg",
},
{
id: 2,
path: "../img/a1-02.jpeg",
},
{
id: 20,
path: "../img/a1-03.jpeg",
},
]
const res = IMGS.filter((img) => img.id >= 18 && img.id < 30)
console.log(res)
Source: stackoverflow.com
Related Query
- How Use images from javascript array in react using filter and map function
- how to map an array of images and use it as inline style in React
- I want to map my array from an object using react and next.js, it's a function component using hooks
- How can I use Map function for an Array with values and another array as a value in Javascript
- How to use images from sharp module in React and Webpack project
- How to send data from react and use the request body in express, using Axios?
- How to reduce and get value from object array using javascript
- In React Hooks. How to set state to a random number and use that to display a string from an array
- React : how to pass and array from inside a Function to the return (JSX)
- How to pass function from FUNCTIONAL to CLASS component and access it outside of render( without prop ), using context in react js?
- How to return only 1 item in an array in react using map function
- How can use my object like a array using with map function
- How to use the useHook in the component rather than passing the value returned from it as a prop to the components using react and typescript?
- Map inside map in react ( one is local array of images and the other is title from json )
- How to dynamically and conditionally render select options inside of a map function using React Hooks
- how to use javascript filter using an id from html element from another component
- How to use a javascript function from a React js component
- How to extract only values from array of objects and put it to an array using react and javascript?
- How to pass a json array that comes from backend to child component using props and react hooks?
- How to add an image in the first react component and ignore in rest of the components using map function
- How to output array with keys to my html file from promise function using React
- Map an array from a JSON file using modern Javascript and push it on a table
- How can I return an array from function and use it's elements as a JSX
- how do i turn data from my api to array i cant use map function so i want to turn cart.cartItems into an array
- How to create Material-UI nested style object from array using map in React
- How do I return a JSON array in React from a local file and have it map through all of my items?
- React : how to display images from array into carousel with its thumbnail on using react-image-gallery
- how to use this map function in React to call url with images name
- React Hooks: How can I use a hook to map an array from a dumb component
- How to use filter from an array while fetching graphql query and also must keep the array order?
More Query from same tag
- Dark Dropdown items in React Bootstrap
- console.log() above import statements in root file does not execute before import
- How to redirect to 404 if particular dynamic page is unavailable in react
- Creating a createSelector in Redux that does not rerender unrelated components
- Uploading an image file with Express.js, React, and MySQL
- Displaying custom field as well as mapped fields separately - reactJS
- React onSubmit passing props
- SVG's tabIndex is not working in IE and React
- Firebase - collection.doc is not a function
- Reactjs-tables. How to join multiple values into 1 cell?
- Number of console logs in component body not equal to number of rerenders?
- How do I embed global React components in Docusaurus v2?
- How to use router for switching between components with a key value pair in react
- Unable to update product using react but can update using postman
- How to change Title icon in semantic UI React Accordion
- How do I use ActionCable client in react static page for the Rails5(API mode) app?
- Wrapping application routes for children with React-Router-4
- How can I pass a DOM element to an HTML attribute? ReactJs/ Javascript
- Convert this CURL Command to Javascript fetch()
- Making sidebar available for all components | React JS | React Router v6
- CRUD Delete all users
- Unable to properly setup navbar in responsive mode using Next JS and Chakra UI
- change select element color to another when open
- How to setup babel-plugin-react-css-modules in create-react-app?
- problem with saved username and passwords on register page
- Why would we use useEffect without a dependency array?
- How do I use data that I fetched from DB in useState?
- Video inside public folder is not playing
- Adding target=_blank to link tag in button in react does not open new page but disables it?
- Call function only in specific state in React with Hooks