File tree Expand file tree Collapse file tree 3 files changed +15
-16
lines changed
projects/js-packages/charts/src/components/single-chart-context Expand file tree Collapse file tree 3 files changed +15
-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 { useChartInstanceContext , useSingleChartContext } from './use-single-chart-context' ;
7
3
export type {
8
4
ChartInstanceContextValue ,
9
5
ChartInstanceRef ,
Original file line number Diff line number Diff line change 1
- import { createContext , useContext } from 'react' ;
1
+ import { createContext } from 'react' ;
2
2
3
3
export interface ChartInstanceRef {
4
4
getScales : ( ) => { xScale : unknown ; yScale : unknown } | null ;
@@ -19,16 +19,7 @@ export interface ChartInstanceContextValue {
19
19
20
20
export const ChartInstanceContext = createContext < ChartInstanceContextValue | null > ( null ) ;
21
21
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
-
30
22
// Backward compatibility exports
31
23
export const SingleChartContext = ChartInstanceContext ;
32
24
export type SingleChartContextValue = ChartInstanceContextValue ;
33
25
export 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 useChartInstanceContext = ( ) : 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
+ } ;
11
+
12
+ export const useSingleChartContext = useChartInstanceContext ;
You can’t perform that action at this time.
0 commit comments