Distribution Select Introduction
Installation
yarn add @procore/labs-distribution-select
Dependencies
@procore/core-react
and react
are listed as external peer dependencies. The package will not bundle the code, and requires the app client to provide it as a dependency
. The external peer dep is to assure React Context is consistent in a client's React tree, the child consumers can reference the correct parent provider. If the package uses latest features or bug fixes and a new minimum version of core-react is required, it should be considered a breaking change as the peer dependency version must be met.
Usage
import {
DistributionSelect,
DistributionSelectProvider,
DistributionContact,
} from '@procore/labs-distribution-select';
export const Demo = () => {
const [value, setValue] = useState<DistributionContact[]>([])
return (
<DistributionSelectProvider
projectId={1}
companyId={2}
>
<DistributionSelect
value={value}
onChange={(v) => setValue(v)}
variant="project" // or "company" or "mixed"
/>
</DistributionSelectProvider>
)
}
DistributionSelectProvider
is responsible for making API calls and storing fetched data. There must be at least one provider in application component tree.