- Move the JsonTree component and the other components to twenty-ui - Rely on a React Context to provide translations ## Future work It would be good to migrate the `createRequiredContext` function to `twenty-ui`. I didn't want to migrate it in this PR but would have liked to use it.
16 lines
415 B
TypeScript
16 lines
415 B
TypeScript
import { JsonTreeContext } from '@ui/json-visualizer/contexts/JsonTreeContext';
|
|
import { useContext } from 'react';
|
|
import { isDefined } from 'twenty-shared';
|
|
|
|
export const useJsonTreeContextOrThrow = () => {
|
|
const value = useContext(JsonTreeContext);
|
|
|
|
if (!isDefined(value)) {
|
|
throw new Error(
|
|
'useJsonTreeContextOrThrow must be used within a JsonTreeContextProvider',
|
|
);
|
|
}
|
|
|
|
return value;
|
|
};
|