react-native-webview / react-native-webview

React Native Cross-Platform WebView
https://github.com/react-native-community/discussions-and-proposals/pull/3
MIT License
6.3k stars 2.95k forks source link

Error: Text strings must be rendered within a <Text> component. #3398

Closed JoseVov closed 2 months ago

JoseVov commented 2 months ago

Bug description: Error: Text strings must be rendered within a component.

To Reproduce: You install, import, and use it.

It's happening to me as the most basic mode

<WebView source={{ uri: 'https://reactnative.dev/' }} style={{ flex: 1 }} />;

Expected behavior: Display the webview with the page provided instead of showing that error

Screenshots/Videos:

simulator_screenshot_F22B0A54-680B-4D6E-BB72-FC512E66E2B6

https://github.com/react-native-webview/react-native-webview/assets/96314055/26b68066-6b21-4b7d-bbb4-5b7e20a0b68a

Environment:

vinamrahalgar commented 1 month ago

Any idea on how to fix this

JoseVov commented 1 month ago

Any idea on how to fix this

Check your JSX, I remember that I had an extra character in the JSX causing that.

vinamrahalgar commented 1 month ago

const WebViewScreen = () => { const route = useRoute(); const mapURL = route?.params;

return (

;

); };

This is the code and url console is - url:: http://www.microsoft.com

JoseVov commented 1 month ago

Probably the ;. Remove the ; in this line -> <WebView source={{ uri: mapURL }} />;