How to use the reakit-utils/toArray.toArray function in reakit-utils

To help you get started, we’ve selected a few reakit-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github reakit / reakit / packages / reakit-system / src / createHook.ts View on Github external
export function createHook(options: CreateHookOptions) {
  const composedHooks = toArray(options.compose) as Hook[];

  const __useOptions = (hookOptions: O, htmlProps: P) => {
    // Call the current hook's useOptions first
    if (options.useOptions) {
      hookOptions = options.useOptions(hookOptions, htmlProps);
    }
    // If there's name, call useOptions from the system context
    if (options.name) {
      hookOptions = useOptions(options.name, hookOptions, htmlProps);
    }
    return hookOptions;
  };

  const useHook: Hook = (
    hookOptions = {} as O,
    htmlProps = {} as P,
github reakit / reakit / packages / reakit / src / Form / utils / setIn.ts View on Github external
export function unstable_setIn<
  T extends Record | Array,
  P extends DeepPath
>(object: T, path: P, value: any): T {
  const pathArray = toArray(path) as DeepPathArray;
  const [key, ...keys] = pathArray;

  if (key == null) return object;

  const obj = isInteger(key) ? object || [] : object || {};
  const result = keys.length ? unstable_setIn(obj[key], keys, value) : value;

  if (isInteger(key)) {
    if (object) {
      return [
        ...object.slice(0, Number(key)),
        result,
        ...object.slice(Number(key) + 1)
      ] as T;
    }
    return [result] as T;