Skip to content

Commit df8f301

Browse files
Use 'trim()' method in useContext page to prevent form from accepting whitespaces (#6549)
1 parent 8d2664b commit df8f301

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/content/reference/react/useContext.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ function LoginForm() {
457457
const {setCurrentUser} = useContext(CurrentUserContext);
458458
const [firstName, setFirstName] = useState('');
459459
const [lastName, setLastName] = useState('');
460-
const canLogin = firstName !== '' && lastName !== '';
460+
const canLogin = firstName.trim() !== '' && lastName.trim() !== '';
461461
return (
462462
<>
463463
<label>

0 commit comments

Comments
 (0)