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
#!/bin/bash | |
# Install required tools | |
sudo aptitude install squashfs-tools genisoimage | |
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
package queue | |
import ( | |
"container/list" | |
"sync" | |
) | |
// Queue is a thread-safe FIFO queue implemented on top of a linked list. | |
type Queue struct { | |
list list.List |
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 withHook from 'with-hook'; | |
class HookedInput extends React.PureComponent { | |
render() { | |
const WithFormInputProps = withHook(useFormInput); | |
return ( | |
<WithFormInputProps> | |
{({ value, onChange }) => <input value={value} onChange={onChange} />} | |
</WithFormInputProps> |
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
class WindowInfo extends React.PureComponent { | |
render() { | |
const WithWindowWidth = withHook(() => { | |
const [width, setWidth] = useState(window.innerWidth); | |
const handleWindowResize = () => setWidth(window.innerWidth); | |
useEffect(() => { | |
window.addEventListener('resize', handleWindowResize); | |
return () => window.removeEventListener('resize', handleWindowResize); | |
}); |
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 withHooksSupport from 'with-hooks-support'; | |
class Input extends React.PureComponent { | |
render() { | |
const { value, onChange } = useFormInput('Take 2!'); | |
return <input value={value} onChange={onChange} />; | |
} | |
} | |
export default withHooksSupport(Input); |
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
class HookedInput extends React.PureComponent { | |
render() { | |
// `withHook` creates a new function component that calls `useFormInput` | |
// that passes the return value to its children. | |
const WithFormInputProps = withHook(useFormInput); | |
return ( | |
<WithFormInputProps> | |
{({ value, onChange }) => <input value={value} onChange={onChange} />} | |
</WithFormInputProps> | |
); |
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
class withHooksSupport(Component) { | |
return class ComponentWithHooksSupport extends Component { | |
// TODO | |
} | |
} |
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 withHooksSupport(Component) { | |
return class ComponentWithHooksSupport extends Component { | |
render() { | |
const WithHook = withHook(() => super.render()); | |
return ( | |
<WithHook> | |
{superRenderReturnValue => superRenderReturnValue} | |
</WithHook> | |
); | |
} |
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 withHooksSupport(Component) { | |
return class ComponentWithHooksSupport extends Component { | |
render() { | |
const withHook = (useHook) => { | |
return ({ children }) => { | |
const returnValue = useHook(); | |
return children(returnValue); | |
} | |
} |
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 withHooksSupport(Component) { | |
return class ComponentWithHooksSupport extends Component { | |
render() { | |
const withHook = (useHook) => { | |
return () => useHook(); | |
} | |
const WithHook = withHook(() => super.render()); | |
return <WithHook />; | |
} |
OlderNewer