I'm trying to convert my class component to a functional component using React Hooks. I'm not sure what to do with this code snippet:
this.setState({
pinError: !isValidPin,
pin: updatedPin,
});
I was thinking of maybe deleting it completely? This is what I have so far:
const PinInput = ({pinError, pin, isInputActive}) => {
const handleValidatePinDigit = (e) => {
const isValidPin = isValidPinDigit(e.target.value);
const updatedPin = isValidPin ? e.target.value : '';
this.setState({
pinError: !isValidPin,
pin: updatedPin,
});
if (get(updatedPin, 'length', '') === 4) {
onComplete(updatedPin);
} else {
onChange(updatedPin);
}
};
};