File tree Expand file tree Collapse file tree 3 files changed +13
-16
lines changed
projects/js-packages/charts/src/components/single-chart-context Expand file tree Collapse file tree 3 files changed +13
-16
lines changed Original file line number Diff line number Diff line change 1- export {
2- SingleChartContext ,
3- ChartInstanceContext ,
4- useChartInstanceContext ,
5- useSingleChartContext ,
6- } from './single-chart-context' ;
1+ export { SingleChartContext , ChartInstanceContext } from './single-chart-context' ;
2+ export { useSingleChartContext } from './use-single-chart-context' ;
73export type {
84 ChartInstanceContextValue ,
95 ChartInstanceRef ,
Original file line number Diff line number Diff line change 1- import { createContext , useContext } from 'react' ;
1+ import { createContext } from 'react' ;
22
33export interface ChartInstanceRef {
44 getScales : ( ) => { xScale : unknown ; yScale : unknown } | null ;
@@ -19,16 +19,7 @@ export interface ChartInstanceContextValue {
1919
2020export const ChartInstanceContext = createContext < ChartInstanceContextValue | null > ( null ) ;
2121
22- export const useChartInstanceContext = ( ) : ChartInstanceContextValue => {
23- const context = useContext ( ChartInstanceContext ) ;
24- if ( ! context ) {
25- throw new Error ( 'useChartInstanceContext must be used within a Chart component' ) ;
26- }
27- return context ;
28- } ;
29-
3022// Backward compatibility exports
3123export const SingleChartContext = ChartInstanceContext ;
3224export type SingleChartContextValue = ChartInstanceContextValue ;
3325export type SingleChartRef = ChartInstanceRef ;
34- export const useSingleChartContext = useChartInstanceContext ;
Original file line number Diff line number Diff line change 1+ import { useContext } from 'react' ;
2+ import { ChartInstanceContextValue , ChartInstanceContext } from './single-chart-context' ;
3+
4+ export const useSingleChartContext = ( ) : ChartInstanceContextValue => {
5+ const context = useContext ( ChartInstanceContext ) ;
6+ if ( ! context ) {
7+ throw new Error ( 'useChartInstanceContext must be used within a Chart component' ) ;
8+ }
9+ return context ;
10+ } ;
You can’t perform that action at this time.
0 commit comments