-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Property 'document' doesn't exist #188
Comments
I have the same issue, @zekoliman did you found a solution for it? |
@pedrozok I spent two days but unfortunately I couldn't find a solution. |
same here, any solutions yet? UPD: Environment: pck versions:
provider: import type { PropsWithChildren } from 'react'
import { useContext } from 'react'
import { createContext } from 'react'
import { useWebViewMessage } from 'react-native-react-bridge'
import { WebView } from 'react-native-webview'
import { ErrorHandler } from '@/core'
import { WitnessRequestTypes, WitnessResponseTypes } from './enums'
import WebApp from './WebApp'
const witnessCalcContext = createContext<{
executeWitnessCalculator: <Inputs>(binary: Uint8Array, inputs: Inputs) => Promise<string>
}>({
executeWitnessCalculator: async () => {
throw new TypeError('not implemented')
},
})
export const useWitnessCalc = () => {
return useContext(witnessCalcContext)
}
export const WitnessCalcProvider = ({ children }: PropsWithChildren) => {
let promiseResolver: any
const { ref, onMessage, emit } = useWebViewMessage(message => {
if (message.type === WitnessResponseTypes.WitnessCalculatorResponse) {
promiseResolver(message.data)
}
})
async function executeWitnessCalculator<Inputs>(
binary: Uint8Array,
inputs: Inputs,
): Promise<string> {
emit({
type: WitnessRequestTypes.WitnessCalculatorRequest,
data: {
binary,
inputs,
},
})
return new Promise(resolve => {
promiseResolver = resolve
})
}
return (
<witnessCalcContext.Provider
value={{
executeWitnessCalculator,
}}
>
<WebView
ref={ref}
source={{ html: WebApp }}
onMessage={onMessage}
onError={ErrorHandler.process}
/>
{children}
</witnessCalcContext.Provider>
)
} the provider itself wrapped nested router, NOT the whole app, but in this case it ain't works too
WebApp.tsx import { emit, useNativeMessage, webViewRender } from 'react-native-react-bridge/lib/web'
import { WitnessRequestTypes, WitnessResponseTypes } from '@/utils/zkp/enums'
function WebApp() {
useNativeMessage(message => {
if (message.type === WitnessRequestTypes.WitnessCalculatorRequest) {
emit({
type: WitnessResponseTypes.WitnessCalculatorResponse,
data: message.data,
})
}
})
return <></>
}
export default webViewRender(<WebApp />) UPD: I was able to avoid this error by replace in source like so:
and also run simple scripts with:
but anyway, the post messages ain't works with this example:
and, i think, that kind of flow is roughly limits most of real case projects |
+1 |
Platform:
The text was updated successfully, but these errors were encountered: