File tree Expand file tree Collapse file tree 1 file changed +7
-10
lines changed
src/components/provider/WebBridgeProvider Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change 11import type { ReactNode } from "react" ;
22import { createContext , useContext , useEffect } from "react" ;
33
4- declare global {
5- interface Window {
6- response : {
7- receiveScanResult : ( jsonData : string ) => void ;
8- } ;
9- }
10- }
11- // window.response = window.response || {};
12-
134interface WebBridgeMessage {
145 type : string ;
156 payload ?: unknown ;
@@ -41,7 +32,13 @@ export function WebBridgeProvider({ children }: WebBridgeProviderProps) {
4132 } ;
4233
4334 useEffect ( ( ) => {
44- window . response = window . response || { } ;
35+ if ( typeof window !== "undefined" && ! window . response ) {
36+ window . response = {
37+ receiveScanResult : ( jsonData : string ) => {
38+ console . log ( "Received scan result:" , jsonData ) ;
39+ } ,
40+ } ;
41+ }
4542 } , [ ] ) ;
4643
4744 return < WebBridgeContext . Provider value = { { receive } } > { children } </ WebBridgeContext . Provider > ;
You can’t perform that action at this time.
0 commit comments