4

I want to import a js library(react-native-webview-bridge) in my react-native project.but my project use typescript,and the library is js.when i import it, it tips '[ts] connot find module react-native-webview-bridge'.so i want to know how to transfer js to typescript,or other way to deal it.thanks!

import * as WebView from 'react-native-webview-bridge'

1 Answer 1

1

from their GitHub i understand you need change the 'WebView' to 'WebViewBridge'.

** CommonJS style **

var WebViewBridge = require('react-native-webview-bridge');

** ES6/ES2015 style **

import WebViewBridge from 'react-native-webview-bridge';

Sign up to request clarification or add additional context in comments.

4 Comments

thanks for you answer.but my project use typescript, not javascript,so cannot import directly.
You can also use require require("script!../lib/d3.js"); inside your typescript.
your mean is? var webView = require('script!react-native-webview-bridge')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.