Last active
March 3, 2020 10:54
-
-
Save treyhuffine/ac0ea540a127abc41f9de78fca43caf8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react'; | |
interface IUser { | |
username: string; | |
email: string; | |
password: string; | |
} | |
const ComplexState = ({ initialUserData }) => { | |
const [user, setUser] = React.useState<IUser | null>(initialUserData); | |
if (!user) { | |
// do something else when our user is null | |
} | |
return ( | |
<form> | |
<input value={user.username} onChange={e => setUser({...user, username: e.target.value})} /> | |
<input value={user.email} onChange={e => setUser({...user, email: e.target.value})} /> | |
<input value={user.password} onChange={e => setUser({...user, password: e.target.value})} /> | |
</form> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Typo?
React.userState -> React.useState