score:0
you use the map function in the render() function. like
{ this.props.questions.map((question)=>{
<div id="question">
{question.id} :- {question.text}
<h3>correct answer:- {question.correct}</h3>
<h3>your answer:- {get answer from question id}</h3>
</div>
)}
score:2
try the below render()
method with map
function:
render() {
const { questions, useranswer } = this.props;
return(
questions.map((question, i)=>
<div id="question">
{question.id} :- {question.text}
<h3>correct answer:- {question.correct}</h3>
<h3>your answer:- {useranswer[i]}</h3>
</div>
)
)
}
Source: stackoverflow.com
Related Query
- How to loop inside map function using jsx format React JS
- React loop through map and display components
- React table how to show 3 items each row using map loop
- Deleting Collection Item in React - map vs for loop
- Map loop in JSX to generate dynamic table headers in React
- Trying to use map method instead of for loop using React Typescript
- Set style property of elements in a map loop in JSX in React
- React - Loop Through an Array - map of undefined
- React Typescript map loop interface error
- React Native - How to change the style and properties to a pressed row inside a map loop
- React component does not load inside map loop
- When useState update then map loop is not working in array inside of object in useState. React js
- React with TypeScript - map an array of promises returned inside a for loop
- React Component div id will not hide what used in map loop
- Loop or map in React JS
- How to solve map loop not working to print data ( component ) ? React
- How to target a specific element in react map loop
- Loop through array using Map in React throw error
- How to get nested loop value using map function in React js?
- React Not returning Child from map loop when creating SVG from JSON object
- React crashes on array.map even though the map loop isn't being entered
- React for-in loop and map
- How to break loop after 2nd element on react js inside map function
- React Component not rendering within map loop
- Unable to render map loop return in Ionic React
- How to loop through complex object using Map in React
- React (get loop or no results) when call function from map to return total inventory
- React js fill a map using axios inside a for loop
- axios request + react hooks inside map function causes infinite loop
- Loop inside React JSX
More Query from same tag
- React Native: Podfiles causing name collusions
- How to detect page scroll to top in React.js?
- How to handle next Next js Router Queries and Params
- React: How to update the DOM with API results
- Setting an initial value in an text field in redux form
- "Video Player is Loading" "This is a modal window" - How to remove unwanted text in react videojs .m3u8 stream
- React update child state from parent component
- Webpack/React: Convert css in stylesheet in to inline style on element
- How to use lazy loading in data-grid material-ui
- React getInitialState using props
- Show div on tab and onFocus and hide on onBlur
- how to resolve useEffect eslint dependency warning?
- Upgrading a project to React 16 with old dependencies
- React Context for user authentication: "TypeError: setUser is not a function" when logging in with correct credentials
- Arcgis builder custom widget to get specific field and value from user to filter the data
- How to retrieve nested JSON data with useEffect hook and async/await in React
- Solving problem of component failing to rerender after refresh
- Enzyme Shallow rendered instance does not inherit props
- how to apply inline style in react component
- setState inside a useEffect not working in enzyme
- React component styling being overridden by global styling
- Pass user to class with React Router Dom
- useeffect proper use with async function
- usage of purgecss safelist option gives UnhandledPromiseRejectionWarning
- Post request using Fetch not working from componentDidMount
- EmailJS: Only works sometimes
- Do not render certain components on certain routes
- Path to endpoint isn't permanent (nginx/react)
- Downloading Excel data using Axios from Laravel backend is not working
- Error: MUI: The data grid component requires all rows to have a unique `id` property