@@ -16,19 +16,19 @@ interface IValueData {
1616 isError : boolean
1717}
1818interface IInspectionsContext {
19- fetchImageData : ( inspectionId : string ) => IImageData
20- fetchAnalysisData : ( inspectionId : string ) => IImageData
21- fetchValueData : ( inspectionId : string ) => IValueData
19+ useImageData : ( inspectionId : string ) => IImageData
20+ useAnalysisData : ( inspectionId : string ) => IImageData
21+ useValueData : ( inspectionId : string ) => IValueData
2222}
2323
2424interface Props {
2525 children : React . ReactNode
2626}
2727
2828const defaultInspectionsContext = {
29- fetchImageData : ( ) => ( { data : undefined , isPending : false , isError : true } ) ,
30- fetchAnalysisData : ( ) => ( { data : undefined , isPending : false , isError : true } ) ,
31- fetchValueData : ( ) => ( { data : undefined , isPending : false , isError : true } ) ,
29+ useImageData : ( ) => ( { data : undefined , isPending : false , isError : true } ) ,
30+ useAnalysisData : ( ) => ( { data : undefined , isPending : false , isError : true } ) ,
31+ useValueData : ( ) => ( { data : undefined , isPending : false , isError : true } ) ,
3232}
3333
3434const InspectionsContext = createContext < IInspectionsContext > ( defaultInspectionsContext )
@@ -85,8 +85,7 @@ export const InspectionsProvider: FC<Props> = ({ children }) => {
8585 }
8686 } , [ registerEvent , connectionReady ] )
8787
88- const fetchImageData = ( inspectionId : string ) : IImageData => {
89- // eslint-disable-next-line react-hooks/rules-of-hooks -- pre-existing design issue, tracked in #2698
88+ const useImageData = ( inspectionId : string ) : IImageData => {
9089 const result = useQuery ( {
9190 queryKey : [ 'fetchInspectionData' , inspectionId ] ,
9291 queryFn : async ( ) => {
@@ -101,8 +100,7 @@ export const InspectionsProvider: FC<Props> = ({ children }) => {
101100 return { data : result . data , isPending : result . isPending , isError : result . isError }
102101 }
103102
104- const fetchAnalysisData = ( inspectionId : string ) : IImageData => {
105- // eslint-disable-next-line react-hooks/rules-of-hooks -- pre-existing design issue, tracked in #2698
103+ const useAnalysisData = ( inspectionId : string ) : IImageData => {
106104 const result = useQuery ( {
107105 queryKey : [ 'fetchAnalysisData' , inspectionId ] ,
108106 queryFn : async ( ) => {
@@ -116,8 +114,7 @@ export const InspectionsProvider: FC<Props> = ({ children }) => {
116114 return { data : result . data , isPending : result . isPending , isError : result . isError }
117115 }
118116
119- const fetchValueData = ( inspectionId : string ) : IValueData => {
120- // eslint-disable-next-line react-hooks/rules-of-hooks -- pre-existing design issue, tracked in #2698
117+ const useValueData = ( inspectionId : string ) : IValueData => {
121118 const result = useQuery ( {
122119 queryKey : [ 'fetchValueData' , inspectionId ] ,
123120 queryFn : async ( ) => {
@@ -134,9 +131,9 @@ export const InspectionsProvider: FC<Props> = ({ children }) => {
134131 return (
135132 < InspectionsContext . Provider
136133 value = { {
137- fetchImageData ,
138- fetchAnalysisData ,
139- fetchValueData ,
134+ useImageData ,
135+ useAnalysisData ,
136+ useValueData ,
140137 } }
141138 >
142139 { children }
0 commit comments