How to use the uncontrollable/hook function in uncontrollable

To help you get started, we’ve selected a few uncontrollable 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 react-bootstrap / react-bootstrap / src / Alert.js View on Github external
const Alert = React.forwardRef((uncontrolledProps, ref) => {
  const {
    bsPrefix,
    show,
    closeLabel,
    className,
    children,
    variant,
    onClose,
    dismissible,
    transition: Transition,
    ...props
  } = useControllable(uncontrolledProps, controllables);

  const prefix = useBootstrapPrefix(bsPrefix, 'alert');
  const handleClose = useEventCallback(e => {
    onClose(false, e);
  });

  const alert = (
github jquense / topeka / src / BindingContext.tsx View on Github external
function BindingContext(
  uncontrolledProps: Props
) {
  let {
    value: model,
    onChange,
    getter,
    setter,
    children,
  }: Props = useUncontrolled(uncontrolledProps, { value: 'onChange' })

  if (process.env.NODE_ENV !== 'production') {
    setter = wrapSetter(setter!)
  }

  const updateBindingValue = useCallback(
    (mapValue, args) => {
      let paths: string[] = []

      Object.keys(mapValue).forEach(key => {
        let field = mapValue[key]
        let value

        if (typeof field === 'function') value = field(...args)
        else if (field === '.' || field == null || args[0] == null)
          value = args[0]

uncontrollable

Wrap a controlled react component, to allow specific prop/handler pairs to be uncontrolled

MIT
Latest version published 9 months ago

Package Health Score

74 / 100
Full package analysis