Last active
July 30, 2021 03:44
-
-
Save jasonleehodges/01c88ab1a297686303feac4e25441b03 to your computer and use it in GitHub Desktop.
Entanglement Example with Context Flag :(
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 React, { FC } from 'react'; | |
import styles from './createUser.module.css'; | |
import { useParams } from 'react-router-dom' | |
export interface Contact { | |
name: string, | |
email: string, | |
phoneNumber: string, | |
referredBy?: string, | |
} | |
interface Props { | |
user: Contact; | |
setUser: (property: keyof Contact) => (e: React.ChangeEvent<HTMLInputElement>) => void; | |
} | |
export const CreateUser: FC<Props> = ({ user, setUser }) => { | |
const { page } = useParams<{ page: string }>(); | |
const isProspect = page === 'prospect'; | |
return ( | |
<form className={styles.create__user}> | |
<label>Name</label> | |
<input value={user.name} onChange={setUser('name')} /> | |
<label>Email</label> | |
<input value={user.email} onChange={setUser('email')} /> | |
<label>Phone Number</label> | |
<input value={user.phoneNumber} onChange={setUser('phoneNumber')} /> | |
{ | |
isProspect && | |
<> | |
<label>Referred By</label> | |
<input value={user.referredBy} onChange={setUser('referredBy')} /> | |
</> | |
} | |
</form> | |
) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment