@prezly/react-promise-modal
Version:
The proper (and easy) way of doing modals in React. With Promises.
20 lines (19 loc) • 668 B
JavaScript
;
var _react = require("react");
var React = _react;
/**
* @see https://streamich.github.io/react-use/?path=/story/state-uselatest--docs
*
* React state hook that returns the latest state as described in the React hooks FAQ.
* @see https://reactjs.org/docs/hooks-faq.html#why-am-i-seeing-stale-props-or-state-inside-my-function
*
* This is mostly useful to get access to the latest value of some props
* or state inside an asynchronous callback, instead of that value
* at the time the callback was created from.
*/
function useLatest(value) {
var ref = React.useRef(value);
ref.current = value;
return ref;
}
exports.useLatest = useLatest;