Cheatography
https://cheatography.com
Frontend interview quick reference lookup
React SetupAdd Script | <script src="foo.com/react.js" crossorigin /> | Add targeting div | <div id="react" /> | Get root Dom | root = document.getElementById("root"); | Bootstrap React | ReactDOM.render(<App />, rootElement); |
React Hooksconst [state, setState] = useState(initialState); | useEffect(() => { ...logic, return cleanup}, [deps]); | useMemo(() => computeExpensiveValue(a, b), [a, b]); | Context ThemeContext = React.createContext(themes.light); <ThemeContext.Provider value={themes.dark}> theme = useContext(ThemeContext); background: theme.background | useRef const inputEl = useRef(null); <input ref={inputEl} /> inputEl.current.focus(); |
async useEffectuseFetch = (param) => {
const [state, setState] = useState([]);
useEffect(() => {
async function fetchData() {
const response = await fetch('url');
const data = await response.json();
setState((prev) => prev.concat(data.results));
}
fetchData();
}, [param]);
return { state };
};
|
| | JS ArraysInsert at Start | unshift() | Insert at End | push() | Insert at Location | splice(start, 0, item2, itemN) | Remove First | shift() | Remove Last | pop() | Remove at Location | splice(start, deleteCount) | Get parts | slice(start, end) |
AlgosDFS | getNodes(root) [...getNodes(root.left), getNodes(root.right)] | BFS | while(queue.length) for(queue.length) node = queue.shift() queue.push(node.left/right) |
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets