* Removed last old DropdownButton * Update front/src/modules/ui/view-bar/components/SingleEntityFilterDropdownButton.tsx Co-authored-by: Thaïs <guigon.thais@gmail.com> * Fix CI --------- Co-authored-by: Charles Bochet <charlesBochet@users.noreply.github.com> Co-authored-by: Thaïs <guigon.thais@gmail.com> Co-authored-by: Charles Bochet <charles@twenty.com>
24 lines
813 B
TypeScript
24 lines
813 B
TypeScript
import { Context, useContext } from 'react';
|
|
import { RecoilState, useRecoilState } from 'recoil';
|
|
|
|
import { RecoilScopeContext } from '../states/RecoilScopeContext';
|
|
|
|
export function useRecoilScopedFamilyState<StateType>(
|
|
recoilState: (familyUniqueId: string) => RecoilState<StateType>,
|
|
uniqueIdInRecoilScope: string,
|
|
SpecificContext?: Context<string | null>,
|
|
) {
|
|
const recoilScopeId = useContext(SpecificContext ?? RecoilScopeContext);
|
|
|
|
if (!recoilScopeId)
|
|
throw new Error(
|
|
`Using a scoped atom without a RecoilScope : ${
|
|
recoilState('').key
|
|
}, verify that you are using a RecoilScope with a specific context if you intended to do so.`,
|
|
);
|
|
|
|
const familyUniqueId = recoilScopeId + uniqueIdInRecoilScope;
|
|
|
|
return useRecoilState<StateType>(recoilState(familyUniqueId));
|
|
}
|