* wip * - Added scopes on useHotkeys - Use new EditableCellV2 - Implemented Recoil Scoped State with specific context - Implemented soft focus position - Factorized open/close editable cell - Removed editable relation old components - Broke down entity table into multiple components - Added Recoil Scope by CellContext - Added Recoil Scope by RowContext * First working version * Use a new EditableCellSoftFocusMode * Fixes * wip * wip * wip * Use company filters * Refactored FilterDropdown into multiple components * Refactored entity search select in dropdown * Renamed states * Fixed people filters * Removed unused code * Cleaned states * Cleaned state * Better naming * fixed rebase * Fix * Fixed stories and mocked data and displayName bug * Fixed cancel sort * Fixed naming * Fixed dropdown height * Fix * Fixed lint
21 lines
675 B
TypeScript
21 lines
675 B
TypeScript
import { Context, useContext } from 'react';
|
|
import { RecoilState, useRecoilValue } from 'recoil';
|
|
|
|
import { RecoilScopeContext } from '../states/RecoilScopeContext';
|
|
|
|
export function useRecoilScopedValue<T>(
|
|
recoilState: (param: string) => RecoilState<T>,
|
|
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.`,
|
|
);
|
|
|
|
return useRecoilValue<T>(recoilState(recoilScopeId));
|
|
}
|