use-adopt

v4.7.0arrow_drop_down
v4.7.0
STATUS
Passing
DOWNLOADS
0
VISIBILITY
Public
PUBLISHED
6 years ago
SIZE
4 KB
1 contributor
Install use-adopt as a package?
Copied
npm i @bit/giladshoham.react-hooks.use.use-adopt
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
chevron_left
chevron_right

WARNING: Don’t use this, works only for functional components.

useAdopt

Extracts a values from multiple render-prop or FaCC components. This hook is similar to useRenderProp, but it allows to specify a named map of multiple render-prop elements from which to extract values.

Usage

import {useAdopt} from 'react-use';

const FaCC = ({children}) => {
  return children('VALUE-FaCC');
};
const RenderProp = ({render}) => {
  return render('VALUE-RenderProp');
};

const Demo = () => {
  const [fragment, result] = useAdopt({
    facc: <FaCC/>,
    renderProp: <RenderProp/>,
  });

  return (
    <>
      {fragment}
      <div>FaCC: {result.facc[0]}</div>
      <div>Render prop: {result.renderProp[0]}</div>
    </>
  );
};
Help and resources