| 0 | kirasiris | Categories: Tags: , , , ,


Well normally the logic behind a form made with Redux is found in a router in which you probably have destructed some data in a constant such as the following one:

const {
} = req.body;

Then you proceed with the somewhat validation by building an object and an empty array first.

const PostFields = {};
PostFields = req.user.id;

Finally you find yourself creating the logic behind your form in which you might have optional/not_required inputs. In order to do this and prevent the state from always populating the data from DB thus resulting in you not being able to update, you can create the following on any input that you need.

input1 ? (PostFields.input1 = input1) : (PostFiedls.input1 = null);

Basically, the above code can be read as if(?) input1 has data on, make it equal to the data, else(:) make it equal to null.

Leave a Reply

Back to Top