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

215
Views
Is it possible to update props or declare props as var to render sub-component in child component? in NextJS

I build parent and child component name RightFrame, I want to display different component. so I using state to update child component and pass it as props. but I want the child component self can update the state (now props) too. but I know that the rule have to declare props as const so It can't update.

the parent component look like:

const [page, setpage] = useState();

return(
<button onClick={() => setpage("main")} 
...
<RightFrame page={page}/>
);

and RightFrame that have 3 sub-component and I want that to update page by them self to change page (since EditClass and CreateClass is the component that have action that can be cancel, so after cancel by button and go back to render Class by <button onClick={page = "main"})

export default function RightFrame(props) {
  const { page } = props;

  return (
  <>
    {page == "main" && <Class/>}
    {page == "edit" && <EditClass/>}
    {page == "new" && <CreateClass/>}
  </>
)

and that's the problem that I want to solve, so I don't know that it is possible to declare props as var on not.

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

0

You can pass the setPage as props so you can use the function to update it. Example

You can now use setPage in component child
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!