react-native-web icon indicating copy to clipboard operation
react-native-web copied to clipboard

Webview not supported?

Open twiz911 opened this issue 10 years ago • 15 comments

Hi

I'm trying to use the webview component but I'm getting an error in the render() method.

Is webview supported? If not, any idea when it will be?

Many thanks

twiz911 avatar Jul 06 '16 01:07 twiz911

I have a very primitive version, works in Chrome, if this is any use:

export class WebView extends React.Component {

    loadIFrame = () => {
        this.refs.iframe.srcdoc = this.props.source.html ;
        }

    render () {
        setTimeout(this.loadIFrame) ;
        return (
            <iframe ref="iframe" style={{ height: '100%', width: '100%', border: 0, seamless
            </iframe>
            ) ;
        }
    }

It does what I need, no more.

miketheanimal avatar Jul 15 '16 21:07 miketheanimal

WebView is not currently supported (see the README for the list of supported components). I have no plans to look into implementing it yet – other parts of the framework are higher priority for us.

necolas avatar Aug 05 '16 17:08 necolas

Any update on this? I'm needing it too. Would you accept a pull-request?

piranna avatar Aug 03 '17 18:08 piranna

I want it too

damiaozi avatar Aug 04 '17 05:08 damiaozi

Just curious if there would be an issue with X-Frame-Options: SAMEORIGIN? For example, you can't use iframes for some sites. Or would it be used strictly for self-hosted content?

I'm simply raising the question, and am just a react-native-web lurker :)

mikeaustin avatar Aug 04 '17 20:08 mikeaustin

Just curious if there would be an issue with X-Frame-Options: SAMEORIGIN? For example, you can't use iframes for some sites.

There would be problems, but it's possible to disable the header on Electron or on regular browsers by adding an extension to whitelist the site, it's just a matter of showing a note to the users to install it.

piranna avatar Aug 04 '17 20:08 piranna

Then it seems pretty straightforward, either to fork and add it, or maybe add a "contrib" section and pull request so it's available, but not supported. i.e. everything in contrib would be experimental/at-your-own-risk. I understand the maintainers' philosophy, but at the same time it would be nice to have WebView available and for others to be able to contribute to it.

I originally looked at react-native-web to prototype react native apps without the hassle of setting up native. I'm busy with other things, but I've been lurking.

mikeaustin avatar Aug 04 '17 20:08 mikeaustin

Hello, you can find an experimental implementation of WebView at react-native-web-community/react-native-web-webview. It currently supports sources of html (without baseUrl), and uri (simple, or with POST method and application/x-www-form-urlencoded content-type). I plan on adding a prop that opens a new window instead of using an iframe, in order to circumvent CORS issues. Note that WebView seems like a good candidate to never use on the web, since it leads to bad UX most of the time. Nevertheless, it's good to have an implementation ready in order to move on.

Minishlink avatar Oct 02 '17 08:10 Minishlink

Hello, you can find an experimental implementation of WebView at react-native-web-community/react-native-web-webview.

I was planning to do my own implementation with the same repo name, lol :-P I'll review it and see if I can help :-)

piranna avatar Oct 02 '17 09:10 piranna

Cool, thanks! :)

Minishlink avatar Oct 02 '17 09:10 Minishlink

Note that WebView seems like a good candidate to never use on the web, since it leads to bad UX most of the time. Nevertheless, it's good to have an implementation ready in order to move on.

I have been using react-native-web quite extensively in the development of a react-native app, because even with RN's development speed compared to native, development in a browser is still a lot faster (for me, anyway). So having a WebView implementation is really useful.

miketheanimal avatar Oct 02 '17 11:10 miketheanimal

Is there any Possibility to use the WebView for the React-native-web Component. I tried using react-native-web-webview but I didn't get it working in the Web. So, suggest me a component which is helpful for Displaying the HTML content in the Web page.

yarra2296 avatar Jul 30 '18 13:07 yarra2296

Any chance for this? Really interested.

cyberpine avatar Mar 27 '20 11:03 cyberpine

Just use an iframe if the platform is web. It works.

sean-m-oleary avatar Mar 03 '21 02:03 sean-m-oleary

Does any anyone have a functional components example code with iframe? I get the error failed to connect.

sisoalbert avatar Apr 17 '22 06:04 sisoalbert