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
console.log('Task 1'); | |
console.log('Task 2'); | |
fs.readFile('./ridiculously_large_file.txt', (err, data) => { | |
if (err) throw err; | |
console.log('done reading file'); | |
process.exit(); | |
}); | |
console.log('Task 3'); |
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
console.log('Task 1'); | |
console.log('Task 2'); | |
// some time consuming for loop | |
for(let i = 0; i < 1000000000; i++) { | |
} | |
console.log('Task 3'); |
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
// App.js | |
import React from "react"; | |
import "./styles.css"; | |
import MyContext, { MyContextProvider } from "./MyContext"; | |
export default function App() { | |
return ( | |
<div className="App"> | |
<MyContextProvider> |
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
@robot | |
class Greeter { | |
private greeting: string; | |
constructor(message: string) { | |
this.greeting = message; | |
} | |
greet() { | |
return "Hello, " + this.greeting; | |
} | |
} |
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
function Factory(props) { | |
switch (props.component.type) { | |
+ case "A": | |
+ if (props.hard) { | |
+ return <A {...props.component} />; | |
+ } | |
+ return <Acached {...props.component} />; | |
} | |
} |
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
function App() { | |
const [count, setCount] = React.useState(0); | |
+ const [reload, setReload] = React.useState(false); | |
const doStuff = () => { | |
setReload(false); | |
setCount(count + 1); | |
console.log(" Click ---> "); | |
}; | |
+ const hardReload = () => { |
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
function Factory(props) { | |
switch (props.component.type) { | |
case "A": | |
+ return <Acached {...props.component} />; | |
case "B": |
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
function A(props) { | |
console.log("Rendered A"); | |
return <div>A</div>; | |
} | |
const areEqual = (prevProps, nextProps) => { | |
return prevProps.name === nextProps.name; | |
}; | |
const Acached = React.memo(A, areEqual); |
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
function A() { | |
console.log("Rendered A"); | |
return <div>A</div>; | |
} | |
function B() { | |
console.log("Rendered B"); | |
return <div>B</div>; | |
} |
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
function App() { | |
const cards = [ | |
{ | |
name: "shadid", | |
type: "A" | |
}, | |
{ | |
name: "shadid", | |
type: "C" | |
}, |