Commit 409c94b4 authored by baesangjune's avatar baesangjune
Browse files

rm node_modules

parent df52aea8
import _mapContextToProps from './mapContextToProps';
export { _mapContextToProps as mapContextToProps };
import _forwardRef from './forwardRef';
export { _forwardRef as forwardRef };
\ No newline at end of file
import mapContextToProps from './mapContextToProps';
export default (function (Context, prop, Component) {
return mapContextToProps(Context, function (context) {
var _ref;
return _ref = {}, _ref[prop] = context, _ref;
}, Component);
});
\ No newline at end of file
// TypeScript Version: 3.0
declare module '@restart/context/mapContextToProps' {
import * as React from 'react';
type Omit<T, U> = Pick<T, Exclude<keyof T, keyof U>>;
type GetProps<C> = C extends React.ComponentType<infer P> ? P : never;
export interface ContextInjectedComponent<
TComponent,
TInjectedProps,
TExtraProps
>
extends React.ForwardRefExoticComponent<
Omit<GetProps<TComponent>, TInjectedProps> & TExtraProps
> {}
// Single Context
function mapContextToProps<TComponent, TContext, TContextProps, TOwnProps>(
context: React.Context<TContext> | [React.Context<TContext>],
mapToProps: (ctxValue: TContext, props: TOwnProps) => TContextProps,
Component: TComponent,
): ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
function mapContextToProps<TContext, TContextProps, TOwnProps>(
context: React.Context<TContext> | [React.Context<TContext>],
mapToProps: (ctxValue: TContext, props: TOwnProps) => TContextProps,
): <TComponent>(
component: TComponent,
) => ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
// 2 Contexts
function mapContextToProps<
TComponent,
TContext1,
TContext2,
TContextProps,
TOwnProps
>(
context: [React.Context<TContext1>, React.Context<TContext2>],
mapToProps: (
c1: TContext1,
c2: TContext2,
props: TOwnProps,
) => TContextProps,
Component: TComponent,
): ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
function mapContextToProps<TContext1, TContext2, TContextProps, TOwnProps>(
context: [React.Context<TContext1>, React.Context<TContext2>],
mapToProps: (
c1: TContext1,
c2: TContext2,
props: TOwnProps,
) => TContextProps,
): <TComponent>(
component: TComponent,
) => ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
// 3 Contexts
function mapContextToProps<
TComponent,
TContext1,
TContext2,
TContext3,
TContextProps,
TOwnProps
>(
context: [
React.Context<TContext1>,
React.Context<TContext2>,
React.Context<TContext3>
],
mapToProps: (
c1: TContext1,
c2: TContext2,
c3: TContext3,
props: TOwnProps,
) => TContextProps,
Component: TComponent,
): ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
function mapContextToProps<
TContext1,
TContext2,
TContext3,
TContextProps,
TOwnProps
>(
context: [
React.Context<TContext1>,
React.Context<TContext2>,
React.Context<TContext3>
],
mapToProps: (
c1: TContext1,
c2: TContext2,
c3: TContext3,
props: TOwnProps,
) => TContextProps,
): <TComponent>(
component: TComponent,
) => ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
// 4 Contexts
function mapContextToProps<
TComponent,
TContext1,
TContext2,
TContext3,
TContext4,
TContextProps,
TOwnProps
>(
context: [
React.Context<TContext1>,
React.Context<TContext2>,
React.Context<TContext3>,
React.Context<TContext4>
],
mapToProps: (
c1: TContext1,
c2: TContext2,
c3: TContext3,
c4: TContext4,
props: TOwnProps,
) => TContextProps,
Component: TComponent,
): ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
function mapContextToProps<
TContext1,
TContext2,
TContext3,
TContext4,
TContextProps,
TOwnProps
>(
context: [
React.Context<TContext1>,
React.Context<TContext2>,
React.Context<TContext3>,
React.Context<TContext4>
],
mapToProps: (
c1: TContext1,
c2: TContext2,
c3: TContext3,
c4: TContext4,
props: TOwnProps,
) => TContextProps,
): <TComponent>(
component: TComponent,
) => ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
export default mapContextToProps;
}
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import React from 'react';
import forwardRef from './forwardRef';
var getDisplayName = function getDisplayName(Component) {
var name = typeof Component === 'string' ? Component : Component.name || Component.displayName;
return name ? "ContextTransform(" + name + ")" : 'ContextTransform';
};
var ensureConsumer = function ensureConsumer(c) {
return c.Consumer || c;
};
function $mapContextToProps(_ref, Component) {
var maybeArrayOfConsumers = _ref.consumers,
mapToProps = _ref.mapToProps,
displayName = _ref.displayName,
_ref$forwardRefAs = _ref.forwardRefAs,
forwardRefAs = _ref$forwardRefAs === void 0 ? 'ref' : _ref$forwardRefAs;
var consumers = maybeArrayOfConsumers;
if (!Array.isArray(maybeArrayOfConsumers)) {
consumers = [maybeArrayOfConsumers];
}
var SingleConsumer = ensureConsumer(consumers[0]);
function singleRender(props, ref) {
var _extends2;
var propsWithRef = _extends((_extends2 = {}, _extends2[forwardRefAs] = ref, _extends2), props);
return React.createElement(SingleConsumer, null, function (value) {
return React.createElement(Component, _extends({}, propsWithRef, mapToProps(value, props)));
});
}
function multiRender(props, ref) {
var _extends3;
var propsWithRef = _extends((_extends3 = {}, _extends3[forwardRefAs] = ref, _extends3), props);
return consumers.reduceRight(function (inner, Context) {
return function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var Consumer = ensureConsumer(Context);
return React.createElement(Consumer, null, function (value) {
return inner.apply(void 0, args.concat([value]));
});
};
}, function () {
for (var _len2 = arguments.length, contexts = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
contexts[_key2] = arguments[_key2];
}
return React.createElement(Component, _extends({}, propsWithRef, mapToProps.apply(void 0, contexts.concat([props]))));
})();
}
var contextTransform = consumers.length === 1 ? singleRender : multiRender;
return forwardRef(contextTransform, {
displayName: displayName || getDisplayName(Component)
});
}
export default function mapContextToProps(maybeOpts, mapToProps, Component) {
if (arguments.length === 2) return $mapContextToProps(maybeOpts, mapToProps);
return $mapContextToProps({
consumers: maybeOpts,
mapToProps: mapToProps
}, Component);
}
\ No newline at end of file
import React from 'react';
import forwardRef from './forwardRef';
export default function transformContext(Context) {
return forwardRef(function (props) {
return React.createElement(Context.Consumer, null, function (context) {
return React.createElement(Context.Provider, {
value: props.mapToValue(context)
}, props.children);
});
}, {
displayName: 'ContextTransformer'
});
}
\ No newline at end of file
// TypeScript Version: 3.0
declare module '@restart/context/forwardRef' {
import * as React from 'react';
interface ForwardRefOptions<TProps> {
displayName?: string;
propTypes?: React.ValidationMap<TProps>;
defaultProps?: Partial<TProps>;
allowFallback?: boolean;
}
function forwardRef<TRef, TProps>(
renderFn: (
props: TProps & { children?: React.ReactNode },
ref: React.Ref<TRef> | null,
) => React.ReactElement<any> | null,
options?: ForwardRefOptions<TProps>,
): React.ForwardRefExoticComponent<
React.PropsWithRef<TProps> & React.RefAttributes<TRef>
>;
export default forwardRef;
}
"use strict";
exports.__esModule = true;
exports.default = forwardRef;
var _react = _interopRequireDefault(require("react"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function forwardRef(renderFn, _temp) {
var _ref = _temp === void 0 ? {} : _temp,
propTypes = _ref.propTypes,
defaultProps = _ref.defaultProps,
_ref$allowFallback = _ref.allowFallback,
allowFallback = _ref$allowFallback === void 0 ? false : _ref$allowFallback,
_ref$displayName = _ref.displayName,
displayName = _ref$displayName === void 0 ? renderFn.name || renderFn.displayName : _ref$displayName;
var render = function render(props, ref) {
return renderFn(props, ref);
};
return Object.assign(_react.default.forwardRef || !allowFallback ? _react.default.forwardRef(render) : function (props) {
return render(props, null);
}, {
displayName: displayName,
propTypes: propTypes,
defaultProps: defaultProps
});
}
\ No newline at end of file
// TypeScript Version: 3.0
declare module '@restart/context' {
import mapContextToProps from '@restart/context/mapContextToProps';
import forwardRef from '@restart/context/forwardRef';
export { mapContextToProps, forwardRef };
}
"use strict";
exports.__esModule = true;
var _mapContextToProps2 = _interopRequireDefault(require("./mapContextToProps"));
exports.mapContextToProps = _mapContextToProps2.default;
var _forwardRef2 = _interopRequireDefault(require("./forwardRef"));
exports.forwardRef = _forwardRef2.default;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
\ No newline at end of file
"use strict";
exports.__esModule = true;
exports.default = void 0;
var _mapContextToProps = _interopRequireDefault(require("./mapContextToProps"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = function _default(Context, prop, Component) {
return (0, _mapContextToProps.default)(Context, function (context) {
var _ref;
return _ref = {}, _ref[prop] = context, _ref;
}, Component);
};
exports.default = _default;
\ No newline at end of file
// TypeScript Version: 3.0
declare module '@restart/context/mapContextToProps' {
import * as React from 'react';
type Omit<T, U> = Pick<T, Exclude<keyof T, keyof U>>;
type GetProps<C> = C extends React.ComponentType<infer P> ? P : never;
export interface ContextInjectedComponent<
TComponent,
TInjectedProps,
TExtraProps
>
extends React.ForwardRefExoticComponent<
Omit<GetProps<TComponent>, TInjectedProps> & TExtraProps
> {}
// Single Context
function mapContextToProps<TComponent, TContext, TContextProps, TOwnProps>(
context: React.Context<TContext> | [React.Context<TContext>],
mapToProps: (ctxValue: TContext, props: TOwnProps) => TContextProps,
Component: TComponent,
): ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
function mapContextToProps<TContext, TContextProps, TOwnProps>(
context: React.Context<TContext> | [React.Context<TContext>],
mapToProps: (ctxValue: TContext, props: TOwnProps) => TContextProps,
): <TComponent>(
component: TComponent,
) => ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
// 2 Contexts
function mapContextToProps<
TComponent,
TContext1,
TContext2,
TContextProps,
TOwnProps
>(
context: [React.Context<TContext1>, React.Context<TContext2>],
mapToProps: (
c1: TContext1,
c2: TContext2,
props: TOwnProps,
) => TContextProps,
Component: TComponent,
): ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
function mapContextToProps<TContext1, TContext2, TContextProps, TOwnProps>(
context: [React.Context<TContext1>, React.Context<TContext2>],
mapToProps: (
c1: TContext1,
c2: TContext2,
props: TOwnProps,
) => TContextProps,
): <TComponent>(
component: TComponent,
) => ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
// 3 Contexts
function mapContextToProps<
TComponent,
TContext1,
TContext2,
TContext3,
TContextProps,
TOwnProps
>(
context: [
React.Context<TContext1>,
React.Context<TContext2>,
React.Context<TContext3>
],
mapToProps: (
c1: TContext1,
c2: TContext2,
c3: TContext3,
props: TOwnProps,
) => TContextProps,
Component: TComponent,
): ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
function mapContextToProps<
TContext1,
TContext2,
TContext3,
TContextProps,
TOwnProps
>(
context: [
React.Context<TContext1>,
React.Context<TContext2>,
React.Context<TContext3>
],
mapToProps: (
c1: TContext1,
c2: TContext2,
c3: TContext3,
props: TOwnProps,
) => TContextProps,
): <TComponent>(
component: TComponent,
) => ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
// 4 Contexts
function mapContextToProps<
TComponent,
TContext1,
TContext2,
TContext3,
TContext4,
TContextProps,
TOwnProps
>(
context: [
React.Context<TContext1>,
React.Context<TContext2>,
React.Context<TContext3>,
React.Context<TContext4>
],
mapToProps: (
c1: TContext1,
c2: TContext2,
c3: TContext3,
c4: TContext4,
props: TOwnProps,
) => TContextProps,
Component: TComponent,
): ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
function mapContextToProps<
TContext1,
TContext2,
TContext3,
TContext4,
TContextProps,
TOwnProps
>(
context: [
React.Context<TContext1>,
React.Context<TContext2>,
React.Context<TContext3>,
React.Context<TContext4>
],
mapToProps: (
c1: TContext1,
c2: TContext2,
c3: TContext3,
c4: TContext4,
props: TOwnProps,
) => TContextProps,
): <TComponent>(
component: TComponent,
) => ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
export default mapContextToProps;
}
"use strict";
exports.__esModule = true;
exports.default = mapContextToProps;
var _react = _interopRequireDefault(require("react"));
var _forwardRef = _interopRequireDefault(require("./forwardRef"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var getDisplayName = function getDisplayName(Component) {
var name = typeof Component === 'string' ? Component : Component.name || Component.displayName;
return name ? "ContextTransform(" + name + ")" : 'ContextTransform';
};
var ensureConsumer = function ensureConsumer(c) {
return c.Consumer || c;
};
function $mapContextToProps(_ref, Component) {
var maybeArrayOfConsumers = _ref.consumers,
mapToProps = _ref.mapToProps,
displayName = _ref.displayName,
_ref$forwardRefAs = _ref.forwardRefAs,
forwardRefAs = _ref$forwardRefAs === void 0 ? 'ref' : _ref$forwardRefAs;
var consumers = maybeArrayOfConsumers;
if (!Array.isArray(maybeArrayOfConsumers)) {
consumers = [maybeArrayOfConsumers];
}
var SingleConsumer = ensureConsumer(consumers[0]);
function singleRender(props, ref) {
var _extends2;
var propsWithRef = _extends((_extends2 = {}, _extends2[forwardRefAs] = ref, _extends2), props);
return _react.default.createElement(SingleConsumer, null, function (value) {
return _react.default.createElement(Component, _extends({}, propsWithRef, mapToProps(value, props)));
});
}
function multiRender(props, ref) {
var _extends3;
var propsWithRef = _extends((_extends3 = {}, _extends3[forwardRefAs] = ref, _extends3), props);
return consumers.reduceRight(function (inner, Context) {
return function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var Consumer = ensureConsumer(Context);
return _react.default.createElement(Consumer, null, function (value) {
return inner.apply(void 0, args.concat([value]));
});
};
}, function () {
for (var _len2 = arguments.length, contexts = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
contexts[_key2] = arguments[_key2];
}
return _react.default.createElement(Component, _extends({}, propsWithRef, mapToProps.apply(void 0, contexts.concat([props]))));
})();
}
var contextTransform = consumers.length === 1 ? singleRender : multiRender;
return (0, _forwardRef.default)(contextTransform, {
displayName: displayName || getDisplayName(Component)
});
}
function mapContextToProps(maybeOpts, mapToProps, Component) {
if (arguments.length === 2) return $mapContextToProps(maybeOpts, mapToProps);
return $mapContextToProps({
consumers: maybeOpts,
mapToProps: mapToProps
}, Component);
}
\ No newline at end of file
{
"_args": [
[
"@restart/context@2.1.4",
"C:\\Users\\Korea\\Desktop\\2020winter\\search-page"
]
],
"_from": "@restart/context@2.1.4",
"_id": "@restart/context@2.1.4",
"_inBundle": false,
"_integrity": "sha512-INJYZQJP7g+IoDUh/475NlGiTeMfwTXUEr3tmRneckHIxNolGOW9CTq83S8cxq0CgJwwcMzMJFchxvlwe7Rk8Q==",
"_location": "/@restart/context",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@restart/context@2.1.4",
"name": "@restart/context",
"escapedName": "@restart%2fcontext",
"scope": "@restart",
"rawSpec": "2.1.4",
"saveSpec": null,
"fetchSpec": "2.1.4"
},
"_requiredBy": [
"/react-bootstrap"
],
"_resolved": "https://registry.npmjs.org/@restart/context/-/context-2.1.4.tgz",
"_spec": "2.1.4",
"_where": "C:\\Users\\Korea\\Desktop\\2020winter\\search-page",
"author": {
"name": "4Catalyzer"
},
"bugs": {
"url": "https://github.com/react-restart/context/issues"
},
"description": "React context helpers.",
"homepage": "https://github.com/react-restart/context#readme",
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"jest": {
"roots": [
"<rootDir>/test"
],
"setupFiles": [
"<rootDir>/test/index.js"
]
},
"license": "MIT",
"lint-staged": {
"*.js": [
"eslint --fix",
"git add"
],
"*.{json,css,md}": [
"prettier --write --ignore-path .eslintignore",
"git add"
]
},
"main": "index.js",
"module": "es/index.js",
"name": "@restart/context",
"peerDependencies": {
"react": ">=16.3.2"
},
"prettier": {
"printWidth": 79,
"singleQuote": true,
"trailingComma": "all"
},
"publishConfig": {
"access": "public"
},
"release": {
"extends": [
"@4c/semantic-release-config"
],
"pkgRoot": "lib"
},
"repository": {
"type": "git",
"url": "git+https://github.com/react-restart/context.git"
},
"types": "index.d.ts",
"version": "2.1.4"
}
"use strict";
exports.__esModule = true;
exports.default = transformContext;
var _react = _interopRequireDefault(require("react"));
var _forwardRef = _interopRequireDefault(require("./forwardRef"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function transformContext(Context) {
return (0, _forwardRef.default)(function (props) {
return _react.default.createElement(Context.Consumer, null, function (context) {
return _react.default.createElement(Context.Provider, {
value: props.mapToValue(context)
}, props.children);
});
}, {
displayName: 'ContextTransformer'
});
}
\ No newline at end of file
MIT License
Copyright (c) 2018 Jason Quense
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
\ No newline at end of file
# @restart/hooks [![npm][npm-badge]][npm]
A set of utility and general-purpose React hooks.
## Install
```sh
npm install @restart/hooks
```
## Usage
```js
import useInterval from '@restart/hooks/useInterval'
useInterval(() => loop(), 300, false)
```
[npm-badge]: https://img.shields.io/npm/v/@restart/hooks.svg
[npm]: https://www.npmjs.org/package/@restart/hooks
interface Window {
ResizeObserver: ResizeObserver
}
/**
* The ResizeObserver interface is used to observe changes to Element's content
* rect.
*
* It is modeled after MutationObserver and IntersectionObserver.
*/
interface ResizeObserver {
new (callback: ResizeObserverCallback)
/**
* Adds target to the list of observed elements.
*/
observe: (target: Element) => void
/**
* Removes target from the list of observed elements.
*/
unobserve: (target: Element) => void
/**
* Clears both the observationTargets and activeTargets lists.
*/
disconnect: () => void
}
/**
* This callback delivers ResizeObserver's notifications. It is invoked by a
* broadcast active observations algorithm.
*/
interface ResizeObserverCallback {
(entries: ResizeObserverEntry[], observer: ResizeObserver): void
}
interface ResizeObserverEntry {
/**
* @param target The Element whose size has changed.
*/
new (target: Element)
/**
* The Element whose size has changed.
*/
readonly target: Element
/**
* Element's content rect when ResizeObserverCallback is invoked.
*/
readonly contentRect: DOMRectReadOnly
}
interface DOMRectReadOnly {
fromRect(other: DOMRectInit | undefined): DOMRectReadOnly
readonly x: number
readonly y: number
readonly width: number
readonly height: number
readonly top: number
readonly right: number
readonly bottom: number
readonly left: number
toJSON: () => any
}
import useCallbackRef from './useCallbackRef';
import useCommittedRef from './useCommittedRef';
import useEventCallback from './useEventCallback';
import useEventListener from './useEventListener';
import useGlobalListener from './useGlobalListener';
import useInterval from './useInterval';
import useRafInterval from './useRafInterval';
import useMergeState from './useMergeState';
import useMergeStateFromProps from './useMergeStateFromProps';
import useMounted from './useMounted';
import usePrevious from './usePrevious';
import useImage from './useImage';
import useResizeObserver from './useResizeObserver';
export { useCallbackRef, useCommittedRef, useEventCallback, useEventListener, useGlobalListener, useInterval, useRafInterval, useMergeState, useMergeStateFromProps, useMounted, usePrevious, useImage, useResizeObserver, };
"use strict";
exports.__esModule = true;
var _useCallbackRef = _interopRequireDefault(require("./useCallbackRef"));
exports.useCallbackRef = _useCallbackRef.default;
var _useCommittedRef = _interopRequireDefault(require("./useCommittedRef"));
exports.useCommittedRef = _useCommittedRef.default;
var _useEventCallback = _interopRequireDefault(require("./useEventCallback"));
exports.useEventCallback = _useEventCallback.default;
var _useEventListener = _interopRequireDefault(require("./useEventListener"));
exports.useEventListener = _useEventListener.default;
var _useGlobalListener = _interopRequireDefault(require("./useGlobalListener"));
exports.useGlobalListener = _useGlobalListener.default;
var _useInterval = _interopRequireDefault(require("./useInterval"));
exports.useInterval = _useInterval.default;
var _useRafInterval = _interopRequireDefault(require("./useRafInterval"));
exports.useRafInterval = _useRafInterval.default;
var _useMergeState = _interopRequireDefault(require("./useMergeState"));
exports.useMergeState = _useMergeState.default;
var _useMergeStateFromProps = _interopRequireDefault(require("./useMergeStateFromProps"));
exports.useMergeStateFromProps = _useMergeStateFromProps.default;
var _useMounted = _interopRequireDefault(require("./useMounted"));
exports.useMounted = _useMounted.default;
var _usePrevious = _interopRequireDefault(require("./usePrevious"));
exports.usePrevious = _usePrevious.default;
var _useImage = _interopRequireDefault(require("./useImage"));
exports.useImage = _useImage.default;
var _useResizeObserver = _interopRequireDefault(require("./useResizeObserver"));
exports.useResizeObserver = _useResizeObserver.default;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
\ No newline at end of file
export interface UseAnimationFrameReturn {
cancel(): void;
/**
* Request for the provided callback to be called on the next animation frame.
* Previously registered callbacks will be cancelled
*/
request(callback: FrameRequestCallback): void;
/**
* Request for the provided callback to be called on the next animation frame.
* Previously registered callbacks can be cancelled by providing `cancelPrevious`
*/
request(cancelPrevious: boolean, callback: FrameRequestCallback): void;
}
/**
* Returns a controller object for requesting and cancelling an animation freame that is properly cleaned up
* once the component unmounts. New requests cancel and replace existing ones.
*
* ```ts
* const [style, setStyle] = useState({});
* const animationFrame = useAnimationFrame();
*
* const handleMouseMove = (e) => {
* animationFrame.request(() => {
* setStyle({ top: e.clientY, left: e.clientY })
* })
* }
*
* const handleMouseUp = () => {
* animationFrame.cancel()
* }
*
* return (
* <div onMouseUp={handleMouseUp} onMouseMove={handleMouseMove}>
* <Ball style={style} />
* </div>
* )
* ```
*/
export default function useAnimationFrame(): UseAnimationFrameReturn;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment