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

106
Views
How to Call function in loaded component in react from main component?

I wanted to toggle a div in loaded component that div in the same component but the Button for call the function in my main layout component hoe to fix this ? Please help

required button in In Main Component Landing.js import React, { useState } from "react";

//Get Code Toggle
const [isActive, setActive] = useState("false");
const handleToggle = () => {
setActive(!isActive)
};

{isActive ? "Get Code" : "Hide Code"}

Required toggle div in loaded sub component LandingSub1.js

 <div className={`codeview my-4 ${isActive ? "hide" : "show"}`}>
        <pre>Code</pre>
      </div>

https://codesandbox.io/s/call-function-from-main-component-to-inner-component-mp9mgp

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

  1. pass the 'isActive' to your component:

    <LandingSub1 isActive={isActive} />

  2. deconstruct it in your child component:

    const { isActive } = props;

about 4 years ago · Juan Pablo Isaza Report
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!