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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> | |
| <script id="jsbin-javascript"> |
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
| // Providing Context | |
| // ================== | |
| import React, {useState, useEffect} from "react" | |
| const Context = React.createContext() | |
| function ContextProvider({children}) { | |
| const [allPhotos, setAllPhotos] = useState([]) | |
| const [cartItems, setCartItems] = useState([]) |
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
| // Object.values().filter(Boolean) | |
| // ------------------------------- | |
| // Video: https://courses.wesbos.com/account/access/5f69bb13ebaa134ef228e80e/view/455624835 | |
| // Filter undefinded toppings out | |
| const tops = Object.values(toppings).filter(topping => topping !== undefined) | |
| // can also be written as: | |
| const tops = Object.values(toppings).filter(Boolean) | |
| // e.g Boolean(undefined) => will return false | |
| // e.g Boolean(0) => will return false |
OlderNewer