Skip to content

Category: Questions

How to avoid re rendering text input?

I have a TextInput and I don’t want it to re render every time I change the value inside it but I want to be able to change the value inside the input at the push of a button that’s why I haven’t just used defaultValue any solutions?? Answer You can use useRef to save text from text input wi…

Validating not required form fields with Yup?

I want to validate a not required form field with Yup lastname: Yup.string.nullable().notRequired(). I don’t how to proceed further because I have multiple condition to validate the field if the input was given. My validation condition are: Should contain only alphabets. Should be atleast minimum 2 and …

How to convert Moment.js moment to unix timestamp

I see a lot in the Moment.js documentation about getting a Moment from a Unix timestamp. However, I am trying to convert a Moment to a Unix timestamp, and I am not sure how to do that. This is how my moment looks: const myMomentObject = moment(str_time, ‘YYYY-MM-DD’); And I need to convert it to a…