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
| app.use((req, res, next) => { | |
| setTimeout(() => next(), 1500); | |
| }); |
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
| const queryRequest = gql` | |
| query { | |
| users { | |
| id | |
| username | |
| } | |
| } | |
| `; | |
| function UsersWithData() { |
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
| function Users({ users }) { | |
| const [username, setUsername] = useState(""); | |
| const changeUsername = (e) => { | |
| setUsername(e.target.value); | |
| }; | |
| return ( | |
| <main> | |
| <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
| const mutationRequest = gql` | |
| mutation($username: String!) { | |
| createUser(username: $username) { | |
| id | |
| username | |
| } | |
| } | |
| `; | |
| function Users({ users }) { |
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
| const handleCreateUser = () => { | |
| createUser({ | |
| variables: { username }, | |
| optimisticResponse: { | |
| __typename: "Mutation", | |
| // use the uuid library to have a unique ID | |
| createUser: { __typename: "User", id: 123456, username }, | |
| }, |
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
| /* General Scrollbar style */ | |
| ::-webkit-scrollbar { | |
| /*vertical scroll bar*/ | |
| width: 8px; | |
| /*horizontal scroll bar*/ | |
| height: 8px; | |
| border-radius: 20px; | |
| } | |
| ::-webkit-scrollbar-track, |
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
| {usersState.map((user) => { | |
| return ( | |
| <div key={user.id} className={`user`}> | |
| <div>{user.username}</div> | |
| </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
| function Users({ users }) { | |
| return ( | |
| <div className={"root"}> | |
| <div className={"users"}> | |
| {usersState.map((user) => { | |
| return ( | |
| <div key={user.id} className={`user`}> | |
| <div>{user.username}</div> | |
| </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
| function App() { | |
| return <Users users={users} />; | |
| } |
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
| function useBookmarks() { | |
| const [bookmarks, setBookmarks] = useState(() => { | |
| const ls = localStorage.getItem("bookmarks"); | |
| if (ls) return JSON.parse(ls); | |
| else return []; | |
| }); | |
| const toggleItemInLocalStorage = (id) => () => { | |
| const isBookmarked = bookmarks.includes(id); | |
| if (isBookmarked) setBookmarks((prev) => prev.filter((b) => b !== id)); |
OlderNewer