D
D
Demigodd2019-06-10 10:16:17
React
Demigodd, 2019-06-10 10:16:17

How to check the state of a Dirty Form in React?

Imagine there is a Form.js component

// Form.js
<form>
  <input type="text" value="" />
</form>

And the main App.js component in which our forms are imported.
// App.js
<Form />

What are the ways to check this form for change?
Some kind of global method is needed. For example, it is possible that we will have a Save button on the page, which we need to disable if the form is not touched.
// Footer.js
<button onClick={save}>Save</button>.

In general, in what ways on the bare React check the form for Dirty (change).
Yes, coding in React with Angular's thoughts is not an option ...
Here, on Angular, there was a form.$dirty method that returns true or false. But here's the trouble with React)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Alexandrovich, 2019-06-10
@Demigodd

https://github.com/jaredpalmer/formik.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question