How to use the @reach/utils.useUpdateEffect function in @reach/utils

To help you get started, we’ve selected a few @reach/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 reach / reach-ui / packages / tabs / src / index.js View on Github external
export const Tab = forwardRef(function Tab(
  { children, as: Comp = "button", ...rest },
  forwardedRef
) {
  const { isSelected, _userInteractedRef, _onSelect, _id, ...htmlProps } = rest;
  const htmlType =
    Comp === "button" && htmlProps.type == null ? "button" : undefined;

  const ownRef = useRef(null);
  const ref = useForkedRef(forwardedRef, ownRef);

  useUpdateEffect(() => {
    if (isSelected && ownRef.current && _userInteractedRef.current) {
      _userInteractedRef.current = false;
      ownRef.current.focus();
    }
  }, [isSelected]);

  return (

@reach/utils

Internal, shared utilities for Reach UI.

MIT
Latest version published 2 years ago

Package Health Score

85 / 100
Full package analysis

Similar packages