Common Utils For React Component.
(...functions): Function
Create a function which will call all the functions with it's arguments from left to right.
import createChainedFunction from 'rc-util/lib/createChainedFunction';
(prop: string, instead: string, component: string): void
Log an error message to warn developers that prop
is deprecated.
import deprecated from 'rc-util/lib/deprecated';
(config: Object): Object
To generate a mixin which will render specific component into specific container automatically.
import getContainerRenderMixin from 'rc-util/lib/getContainerRenderMixin';
Fields in config
and their meanings.
Field | Type | Description | Default |
---|---|---|---|
autoMount | boolean | Whether to render component into container automatically | true |
autoDestroy | boolean | Whether to remove container automatically while the component is unmounted | true |
isVisible | (instance): boolean | A function to get current visibility of the component | - |
isForceRender | (instance): boolean | A function to determine whether to render popup even it's not visible | - |
getComponent | (instance, extra): ReactNode | A function to get the component which will be rendered into container | - |
getContaienr | (instance): HTMLElement | A function to get the container |
Render children to the specific container;
import Portal from 'rc-util/lib/Portal';
Props:
Prop | Type | Description | Default |
---|---|---|---|
children | ReactChildren | Content render to the container | - |
getContaienr | (): HTMLElement | A function to get the container | - |
(fresh?: boolean): number
Get the width of scrollbar.
import getScrollBarSize from 'rc-util/lib/getScrollBarSize';
(): string
To generate a global unique id across current application.
import guid from 'rc-util/lib/guid';
(props: Object): Object
Pick valid HTML attributes and events from props.
import pickAttrs from 'rc-util/lib/pickAttrs';
(msg: string): void
A shallow wrapper of console.warn
.
import warn from 'rc-util/lib/warn';
A collection of functions to operate React elements' children.
(children): children
Return a shallow copy of children.
import mapSelf from 'rc-util/lib/Children/mapSelf';
(children: ReactNode[]): ReactNode[]
Convert children into an array.
import toArray from 'rc-util/lib/Children/toArray';