question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide option to call change from outside/initialChange

See original GitHub issue

Scope: FormRenderer

Description

In Sources UI I have this following flow:

[ FORM ] > submit 📨 > 💥 ☠️ > [ ERROR_PAGE ] > retry button ♻️ > [ FORM ]

The form has set initialValues. In the submit action, form values and initial values are compared and only modified values are sent to an API.

I need to re-set the values when restarting the form after an error occurs (formValues from the first attempt set in the second attempt). However, I cannot use the initial values, because I am using them to compare new values with initials. (So in the second attempt: formValues = initialValues = no values 😭 )

I propose two ways how to solve this riddle:

1st ) Provide a way how to call onChange outside the form

2nd and maybe preferred ) Provide something like initialChange, which will be called only once and will call change event with provided values after the form renderer is mount

Schema

  <FormRenderer
    schema={schema}
    formFieldsMapper={formFieldsMapper}
    layoutMapper={layoutMapper}
    onSubmit={console.log}
    initialValues={{
       name: 'Mike Johnson'
   }}
    initialChange={{
        name: 'John Smith'
    }}
  />

=> modified fields: name

What do you think, @Hyperkid123 👾 1️⃣ 2️⃣ 3️⃣ ?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
Hyperkid123commented, Jan 6, 2020

The thing is this behavior is very specific. I did play with the idea of exposing the formApi from the get-go but ultimately decided against it and I will be until someone finds some use-case where there is no other way 😄. To be clear the above-proposed solutions are not that simple and clean to implement inside the renderer. I tried.

0reactions
rvsiacommented, Jan 6, 2020

It is possible to compare the first initialValues, and second ones in the submit action but I am just trying to find some clean and simple solution. Alright, I will do it other way, thanks for discussing this! This can be closed now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I change the phone number displaying on outbound ...
From General > Outbound Call Options, set the External Caller ID to Use and then choose the desired phone number. Save your changes....
Read more >
Microsoft Teams Calling - changing call settings - YouTube
This video looks at how to change call settings which include call forwarding your phone, changing the no answer destination, ...
Read more >
Microsoft teams calling plans- External calling set up (5 steps)
Microsoft teams calling plans - External calling By the end of this video you would be able to easily set up users for...
Read more >
Assign, change, or remove a phone number for a user
On the Phone numbers page, select an unassigned number in the list, and then click Edit. In the Edit pane, under Assigned to,...
Read more >
Changing phone settings (web portal) - Zoom Support
Emergency Addresses : Add or update your emergency address provided to first responders when dialing an emergency number. Outbound Caller ID ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found