Reactjs filter where result is zero

I want to have text on the page change when no items from a mapped array are showing.
I am showing a list of questions, but if a question is "answered" (a boolean of answered: true), it is not mapped.

I’m trying to figure out the best way to determine if every item in the array has answered: true, and then change text on the page accordingly. Is it possible to use filter for this when I need a function that checks for no results coming back?

The page shows a list to the left, and the text "please click on a question" to the right. When a question is selected, it replaces "please click on a question" with information about the selected question. But when there are no questions, I want "please click on a question" to show something like "There are currently no questions to answer".

this.state = {
      questions: [],
      currentQuestion: null,
      currentIndex: -1,
      searchQuestion: "",
      wanttodelete: false

{questions &&
    , index) => (
                <div key={index}>
                  {!question.answered &&
                    "list-group-item " +
                    (index === currentIndex ? "active" : "")
                  onClick={() => this.setActiveQuestion(question, index)}
        <div className="col-lg-8 question-area">
          {currentQuestion ? (
                description="Question header"/>
                </label>{" "}
                </label>{" "}
                </label>{" "}
                {currentQuestion.answered ? "Answered" : "Awaiting answer"}

                to={"/questions/" +}
                className="badge badge-warning"
                Answer this question
          ) : (
              <p>Please click on a Question...</p>

163 thoughts on “Reactjs filter where result is zero”

  1. Pingback:
  2. Pingback: viagra prices
  3. Pingback: viagra sale
  4. Pingback: sex pills cialis
  5. Pingback: viagra pills
  6. Pingback: cialis canada
  7. Pingback: sildenafil nz
  8. Pingback: viagra gel caps
  9. Pingback: cialis 10 mg
  10. Pingback: walgreens cialis
  11. Pingback: viagra walmart
  12. Pingback: viagra men
  13. Pingback: viagra dosage
  14. Pingback: viagra ohne rezept
  15. Pingback: viagra jokes
  16. Pingback: viagra online
  17. Pingback: viagra price
  18. Pingback: cheap viagra
  19. Pingback: walmart viagra
  20. Pingback: viagra sildenafil

Leave a Comment