I am developing an app that uses react native webview. Inside the webview I am using a website that was built with ReactJS. In the website, I am using react-to-print library to print the contents of the page by component reference. Now, the problem is - when I use expo with webview (inside of which we have that react website) the printing doesn't work.
Expo React native side:
<View style={{ width: longDimension, height: shortDimension }}>
<WebView
ref={webRef}
source={{ uri: "http://mywebsite.com/" }}
webviewDebuggingEnabled={true}
javaScriptEnabled={true}
onLoad={native_to_web}
onError={errorHandler}
/>
</View>
React JS side:
// this doesn't work inside webview
const handlePrint = useReactToPrint({
content: () => componentRef.current,
});
//...
return (
<div>
<button onClick={print}>Print</button>
<div ref={componentRef}>some content here I want to print</div>
</div>
);
When I tested on iOS device, it shows Can't open url: about:srcdoc. On Android nothing happens
What I expect is printing (some popup is opened where you can choose the printer, etc.)