This file contains 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
state = { | |
name: "Bob", | |
age: 24, | |
hobbies: ["swimming", "hiking"], | |
background: { | |
jobs: ["mechanic", "bank teller"], | |
}, | |
} |
This file contains 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
let name = "Bob" | |
let age = 24 | |
name = age //hey you mutated the name variable! |
This file contains 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
type UserForm = Omit<User, 'id' | 'updated_at'>; |
This file contains 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
interface User { | |
id: string; | |
updated_at: string; | |
username: string; | |
age: number; | |
email: string; | |
} |
This file contains 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
interface User { | |
username: string; | |
age: number; | |
email: string; | |
} | |
const createUser = (user: User) => { | |
//fetch request that requires all User properties | |
} |
This file contains 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
interface CreateUserRequest { | |
username: string; | |
age: number; | |
email: string; | |
} | |
interface UpdateUserRequest { | |
username?: string; | |
age?: number; | |
email?: string; |
This file contains 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, { useState } from 'react'; | |
const initialFormState = { | |
email: '', | |
password: '', | |
passwordConfirm: '' | |
} | |
const Register: React.FC = (): JSX.Element => { | |
const [form, setForm] = useState(initialFormState) |
This file contains 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, { useState } from 'react'; | |
interface FormState { | |
email: string; | |
password: string; | |
passwordConfirm: string; | |
} | |
const initialFormState: FormState = { | |
email: '', |
This file contains 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, { useState } from 'react'; | |
interface FormState { | |
email: string; | |
password: string; | |
passwordConfirm: string; | |
} | |
const initialFormState: FormState = { | |
email: '', |
This file contains 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, { useContext, useEffect, useRef, useState } from 'react'; | |
import { Error } from 'state/firebaseTypes'; | |
import UserModel from 'state/users/userModel'; | |
import { FirestoreContext } from 'context/FirestoreContextProvider'; | |
//would be defined elsewhere | |
type FetchRequest<T, E = unknown> = { fetching: boolean; data: T; error: E | null }; | |
const Users: React.FC = (): JSX.Element => { | |
const [users, setUsers] = useState<FetchRequest<User[], Error>>({ fetching: true, data: [], error: null }); |