Categories
Mastering Development

How do I use react custom hooks to make code reusable

I have two components similar like below: const Login = props => { let loading; const dispatch = useDispatch(); const [notification, setNotification] = React.useState(”); const [hasNotification, setHasNotification] = React.useState(”); const [isLoading, setIsLoading] = React.useState(false); const {status, message} = useSelector(state => state.LoginReducer); const { register, handleSubmit, formState, errors } = useForm({ mode: “onChange” }); const onSubmit […]