• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

205
Views
Force page to re-render through popup

I am new to React. I have a question about how to force the page to render through a popup.

Now I wrote my page in a function component. And it has a popup window that could change the text on the page. However, the update will first go to the backend database and does not show on the page after submitting the popup form.

I know we can use windows.location.reload to reload the whole page. But I would like to know how I can re-render the function component instead of reloading the whole page.

Thank you so much!

Edit: This is a part of the code from the main page. values and setValues are created by [values, setValues] = useState({name: "", birthDate: ""});.

      <PopUpEdit 
        values={values}
        setValues = {setValues}
        trigger={buttonPopUpEdit} 
        setTrigger={setButtonPopUpEdit}
        >
          Edit
      </PopUpEdit> 

In the popup form,

const onSubmit = async(event)=>{
    event.preventDefault();
    props.setValues(event.target.value);
    props.setTrigger(undefined);
}

Both the main page and the popup form are function components. Thank you!

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

0

in react js everything is based on state. you should add useState hook which is rendered with each change.

See also Basic Hook useState

enter image description here

about 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error