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

164
Views
Next JS data handeling

_APP.JS

function MyApp({ Component, pageProps }) {
  let primary = 'darkMode_Primary';
  let secondary = 'darkMode_Secondary'
  return (
    <Layout primary_super={primary} secondary_super={secondary}>
      <Component {...pageProps} />
    </Layout>
  )
}

export default MyApp

LAYOUT.JS

export default function Layout({ children , primary_super, secondary_super}) {

  return (
    <>
      <Navbar  primary={primary_super} secondary={secondary_super}/>
      <main>{children}</main>
      <ModeSwitch primary={primary_super} secondary={secondary_super}/>
    </>
  )
}

NAVBAR.JS

export default function Navbar(props) {

    const click = ()=>{
        console.log('USS')
    }

    const Primary = theme[props.primary]
    const Secondary = theme[props.secondary]
    return (
    <div className="NAV" id="NAV" style={Primary}>
        <div className="NAV_BOX_FULL NAV_LEX" style={Secondary}> 
            <img src="/NAV_img/cat.png" alt="" className="NAV_logo1 NAV_logo"/>
            <h3 className="NAV_head"  onClick={click} >SilenxIka</h3>
        </div>
    </div>
  )
}

what i want to do is, when someone triggers that onClick fuction in navbar.js, the primary and secondary in _app.js

File style: Navbar.js is inside of Layout.js and Layout.js is used in _app.js

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

0

In _app.js you can use state variables for primary and secondary.

like const [primary,setPrimary] = useState(''); etc

Then define a onClickHandler function that would setState values for 'primary' and 'secondary'. You can pass that function to Layout and attach it to onClick

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!