Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
After fetching, data is showing in console but it's not showing in html in react js

Here is my code for App component.

import { nanoid } from "nanoid";
import { useEffect, useState } from "react";
import Quiz from "./Components/Quiz";
import axios from "axios";

export default function App() {

  const [quiz, setQuiz] = useState([]);

  useEffect(() => {
    const newQuiz = [];
    axios.get("https://opentdb.com/api.php?amount=5").then((data) =>
      data.data.results.map((val) =>
        newQuiz.push({
          id: nanoid(),
          question: val.question,
          correctAns: val.correct_answer,
          options: [...val.incorrect_answers, val.correct_answer],
        })
      )
    );
    setQuiz(newQuiz);
  }, []);

  console.log(quiz)
  const quizElements = quiz.map((val) => <Quiz key={val.id} value={val} />);

  return <div>{quizElements}</div>;
}

console.log(quiz) // quiz is printed there in console.

Here is the code for Quiz component.

export default function Quiz(props) {
  return (
    <div>
      <h3>{props.value.question}</h3>
    </div>
  );
}

But In html, It's totally blank. What is the problem here?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!