What happens if you create new object or reset every property?

What happens if you create new object or reset every property?

Leads to repeated code- as gbjbaanb indicated, if you add a parameter to the constructor, everywhere that calls the constructor will fail to compile, there’s no danger of missing a spot. If you just add a public property, you’ll have to be sure to manually find and update every place where objects are “reset”.

Do you reuse the same object in Reset method?

As Harrison Paine and Brandin suggest, I would re-use the same object and factorize the initialization of the properties in a Reset method:

How to reset AutoNumber value in Microsoft Docs?

On the Query menu, click Run. When you are prompted by the “You are about to paste # row (s) into a new table” message, click Yes to insert the rows. On the File menu, click Close, and then click No to close the Make-Table Query window. Click Tables on the left pane, right-click the new table, and then click Design View.

Which is better, instantiating a new object or update the constructor?

Instantiating a new object is always better, then you have 1 place to initialise the properties (the constructor) and can easily update it. Imagine you add a new property to the class, you would rather update the constructor than add a new method that also re-initialises all properties.

Is it possible to reset the state of a function in react?

Your code looks good, but if you want to decrease the functions needed you can put your entire form state in a single state variable object and reset to the initial object. I think the voted answer is still correct, but recently React released the new built-in useReducer which, in their own words, is

What causes react to unmount an old component?

If you want a quick n’ dirty method you could try just changing the component’s key which will cause React to unmount your old component instance and mount a fresh one.