ui5-webcomponents icon indicating copy to clipboard operation
ui5-webcomponents copied to clipboard

React Native

Open alemrsrl opened this issue 6 years ago • 5 comments

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?

alemrsrl avatar Sep 28 '20 06:09 alemrsrl

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?

fifoosid avatar Sep 28 '20 08:09 fifoosid

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

alemrsrl avatar Sep 28 '20 08:09 alemrsrl

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:

image

Do you think that there might be a problem in your app setup?

fifoosid avatar Sep 30 '20 07:09 fifoosid

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

alemrsrl avatar Sep 30 '20 11:09 alemrsrl

Hello @alemrsrl

Here is the code, which is running on my side.

Hope it helps you resolve your issue.

fifoosid avatar Oct 01 '20 14:10 fifoosid