React Native
When i try to use ui5 web components in a react native project, using android simulator i get the error: Requiring module "node_modules@ui5\webcomponents\dist\Button.js", which threw an exception: ReferenceError: Can't find variable: HTMLElement is it possible to use components in a react native project? if so, are there any examples?
or any way to use ui5 webcomponents in a cross platform project?
Hello @alemrsrl
How are you trying to use UI5 Web Components in React Native? Have you tried using WebView as explained in this StackOverflow answer?
this is my App.js code:
*
- @format
- @flow strict-local */
import React from 'react'; import { SafeAreaView, StyleSheet, ScrollView, View, Text, StatusBar, } from 'react-native'; import { WebView } from 'react-native-webview';
import logo from './logo.png'; import TodoList from './TodoList';
import "@ui5/webcomponents/dist/Button";
const App: () => React$Node = () => { return ( <> <WebView source={{ uri: 'https://github.com/facebook/react-native' }} style={{ marginTop: 20 }} /> </> ); };
const styles = StyleSheet.create({ engine: { position: 'absolute', right: 0, }, sectionContainer: { marginTop: 32, paddingHorizontal: 24, }, sectionTitle: { fontSize: 24, fontWeight: '600', }, sectionDescription: { marginTop: 8, fontSize: 18, fontWeight: '400', }, highlight: { fontWeight: '700', }, footer: { fontSize: 12, fontWeight: '600', padding: 4, paddingRight: 12, textAlign: 'right', }, });
export default App;
if i user import "@ui5/webcomponents/dist/Button"; i receive the exception: Requiring module "node_modules@ui5\webcomponents\dist\Button.js", which threw an exception: ReferenceError: Can't find variable: HTMLElement
Hello @alemrsrl
After following the official getting started guide, I was able to create an app, add a couple of UI5 Web Components inside and start the app with no problem. I am attaching a screenshot of the application:

Do you think that there might be a problem in your app setup?
probably, I'm trying to create a cross platform app that run in browser, IOS and android. can you share your code so that i can use it as a sample? thanks
Hello @alemrsrl
Here is the code, which is running on my side.
Hope it helps you resolve your issue.