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
| _ |
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 { useRef, useState } from "react" | |
| import { checkEmail, checkPassword } from "./validators" | |
| export function RefForm() { | |
| const emailRef = useRef() | |
| const passwordRef = useRef() | |
| const [emailErrors, setEmailErrors] = useState([]) | |
| const [passwordErrors, setPasswordErrors] = useState([]) | |
| const [isAfterFirstSubmit, setIsAfterFirstSubmit] = useState(false) |
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 { useLocalStorage } from "./useLocalStorage" | |
| function App() { | |
| const [firstName, setFirstName] = useLocalStorage("FIRST_NAME", "") | |
| const [lastName, setLastName] = useLocalStorage("LAST_NAME", () => { | |
| return "Default" | |
| }) | |
| const [hobbies, setHobbies] = useLocalStorage("HOBBIES", [ |
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 { useState, useCallback } from "react" | |
| export function useArray(initialValue) { | |
| const [array, setArray] = useState(initialValue) | |
| const push = useCallback(element => { | |
| setArray(a => [...a, element]) | |
| }, []) | |
| const replace = useCallback((index, newElement) => { |
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
| _ |
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 { useEffect, useState } from "react"; | |
| import BlogList from "./BlogList"; | |
| import useFetch from "./useFetch"; | |
| const Home = () => { | |
| const { error, isPending, data: blogs } = useFetch('http://localhost:8000/blogs') | |
| return ( | |
| <div className="home"> | |
| { error && <div>{ error }</div> } |
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 { useState } from "react"; | |
| function Cart() { | |
| const [cart, setCart] = useState({ | |
| items: [], | |
| total: 0, | |
| discount: null, | |
| isLoading: false, | |
| }); |
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
| https://jsbin.com/qiyeriziyi/edit?html,css,output | |
| https://jsbin.com/jewegaseyo/edit?html,css,output |
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
| https://jsbin.com/cawipexoma/edit?html,css,output |
NewerOlder