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 useStore = ( | |
[state, dispatch], | |
{ mapStateToProps, mapDispatchToProps, mergeProps }, | |
extraArg | |
) => { | |
const stateProps = useMemo( | |
() => (mapStateToProps != null ? mapStateToProps(state, extraArg) : null), | |
[mapStateToProps, state, extraArg] | |
); | |
const dispatchProps = useMemo( |
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
class Timeout extends React.Component { | |
static LOADED = 0 | |
static LOADING = 1 | |
static TIMED_OUT = 2 | |
state = { mode: Timeout.LOADED } | |
componentDidCatch(maybePromise) { | |
if (!(maybePromise instanceof Promise)) { | |
const notAPromise = maybePromise |
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
class LoaderWithGame extends React.Component { | |
state = { isPlaying: false } | |
startGame = () => this.setState({ isPlaying: true }) | |
endGame = () => this.setState({ isPlaying: false }) | |
render() { | |
return ( | |
<React.Timeout> |
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 LoadsUserWithLoadingSpinner = () => ( | |
<React.Timeout ms={300}> | |
{didTimeout ? ( | |
<p>Loading...</p> | |
) : ( | |
<UsesData /> | |
)} | |
</React.Timeout> | |
) |
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 fetchUser = createDataFetcher('http://website.com/users/me') | |
const UsesData = () => { | |
const user = fetchUser() | |
return ( | |
<div> | |
{user.name} | |
</div> | |
) | |
} |
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 createDataFetcher = (url) => { | |
let result = null | |
let promise = null | |
return () => { | |
if (result != null) { | |
return result; | |
} | |
if (promise === null) { |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
<!doctype html> | |
<title>Dropdown</title> | |
<style> | |
input { | |
box-sizing: border-box; | |
width: 200px; | |
} | |
.options { |
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
<!doctype html> | |
<title>Ripple Carousel</title> | |
<style> | |
input { | |
box-sizing: border-box; | |
width: 200px; | |
} | |
.options { |
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 (root, wrapper) { | |
if (typeof define == "function" && define.amd) define([], function () { | |
return wrapper; | |
});else if (typeof module == "object" && module.exports) module.exports = wrapper;else (root.nbind = root.nbind || {}).init = wrapper; | |
})(this, function (Module, cb) { | |
if (typeof Module == "function") { | |
cb = Module;Module = {}; | |
}Module.onRuntimeInitialized = function (init, cb) { | |
return function () { | |
if (init) init.apply(this, arguments);try { |