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
//using partially applied functions (closures) are used for sorting to | |
// demonstrate how to prevent duplicate implementation and writing | |
// imperative code. Most of your code should express "what it does" | |
// not "how it does it" | |
const data1 = [ | |
{ id: 1, name: 'a', items: [1, 2, 3] }, | |
{ id: 2, name: 'a', items: [1, 2] }, | |
{ id: 3, name: 'b', items: [4, 5] }, | |
{ id: 4, name: 'b', items: [4, 5, 6, 7] }, | |
]; |
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
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
//for Stack overflow snippet that doesn't allow imports | |
const { useRef, useState } = React; | |
const compose = (...fns) => | |
fns.reduce((result, fn) => (...args) => | |
fn(result(...args)) | |
); | |
const mw = () => (next) => (action) => next(action); |
NewerOlder