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 preferredStoreItems=[ | |
| {"PreferredStoreName":"Stater Bros","GroceryItemID":3,"Name":"Test","PreferredStoreID":3,"Notes":"Test","CreatedOn":"Apr 30 2021 10:43PM"}, | |
| {"PreferredStoreName":"Ralph's","GroceryItemID":2,"Name":"Baguette","PreferredStoreID":7,"Notes":"","CreatedOn":"Apr 30 2021 10:43PM"}, | |
| {"PreferredStoreName":"Stater Bros","GroceryItemID":1,"Name":"Saltines","PreferredStoreID":3,"Notes":"","CreatedOn":"Apr 30 2021 6:26AM"}, | |
| ] | |
| const z = preferredStoreItems.reduce((map, item) => { | |
| map.set(item.PreferredStoreID, item.PreferredStoreName); | |
| return map; | |
| }, new Map); |
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
| export default function PreferredStoreItemsForStore({ | |
| PreferredStoreItems: preferredStoreItems, | |
| PreferredStoreName: preferredStoreName, | |
| }) { | |
| ... | |
| } |
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 Foo() { | |
| const handler1 = (event, str) => { | |
| console.log(event, str); | |
| }; | |
| const handler2 = (event) => (str) => { | |
| console.log(event, str); | |
| }; | |
| return ( |
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 runProgram = require('./scrabble'); | |
| runProgram(); |
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 GroupItem({ group, names }) { | |
| const [collapse, setCollapse] = useState(false); | |
| const handleClick = () => { | |
| setCollapse(!collapse); | |
| }; | |
| return ( |
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 foo = { | |
| foo: 'bar', | |
| arr: [1, 2, 3], | |
| }; | |
| foo.arr.forEach((number) => { | |
| console.log(number); | |
| }); |
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 promiseChain() { | |
| return new Promise((resolve) => { resolve('two'); }); | |
| } | |
| console.log('one'); | |
| promiseChain() | |
| .then((result) => { | |
| console.log(result); | |
| }) | |
| .then(() => { |
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
| async function run() { | |
| const response = await fetch('https://foo.com'); | |
| const json = await response.json(); | |
| console.log(json); | |
| } |
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'; | |
| export default function Foo() { | |
| // When we change the state, we cause the component to re-render. | |
| const [count, setCount] = useState(0); | |
| // This gets persisted between re-render | |
| const persisted = useRef(null); | |
| // This does not get persisted between re-render |
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 { useDispatch, useSelector } from 'react-redux'; | |
| import { setCount, selectCount } from './counterSlice'; | |
| export default function App() { | |
| const dispatch = useDispatch(); | |
| const count = useSelector(selectCount); | |
| return ( | |
| <> | |
| <p>{count}</p> |