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

116
Views
Checking a variable in React and using to show an element

I have a redux piece of state that is selected. This will return an array of selections, e.g 3 words or what not.

With this, I want to continually check this variable and show and NOT element if the list is GREATER then 1, eg only show when filtered to 1 selection.

See below code:

const [activeRole, setActiveRole] = useState(false)
const searchResults = useSelector(state => state.jobsearch.roles.map(role => role.title))

  const handleActiveSelection = () => {
    if (searchResults.length > 1) {
      setActiveRole(true)
    }
  }

Would I need to use a useEffect to continually monitor this? How would I embed a clause into my element?

E.g: ONLY show when 1 selection?

          {finalSelection &&  (
            <MessageContainer>
              <Typography>
                You have selected {searchResults}
              </Typography>
            </MessageContainer>
          )}
about 4 years ago · Santiago Trujillo
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!