0

I'm trying to include a link to an external url with key/value pairs prefaced with & using react-native-render-html in an app developed with expo but when I run the code on Expo Go client I've got the error:

TypeError: undefined is not an object (evaluating 'this.entityTrie[0]')

I'm using:

  • expo v. 43.0.2
  • expo-cli v. 4.12.11
  • Expo Go v. 2.22.3
  • react-native-render-html v.6.3.1

I'm running expo-cli on Windows 10 Pro and I've tested the bundle on 2 different devices: one Redmi Note 7 with Android 9 and one Redmi 9C with Android 10.

The most disconcerting thing is that if I generate the .apk with expo and install it on the devices it works.

The code is quite simple:

import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { StyleSheet, Text, useWindowDimensions, View } from 'react-native';
import RenderHtml from 'react-native-render-html';

const source = {
  html: `<a
  href="http://www.fundacioninfosalud.org/verDoc.aspx?id=1023&tipo=2"
  style="text-align:center;">
    A test link!
</a>`
};

export default function App() {
  const { width } = useWindowDimensions();
  return (
    <View style={styles.container}>
      <Text>Open up App.js to start working on your app!</Text>
      <StatusBar style="auto" />
      <RenderHtml
        contentWidth={width}
        source={source}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

I've tried to substitute & by %26 but it does not work.

I've uploaded the code at this git repository.

Anybody would know how I can solve it?

Thanks

pferriol
  • 11
  • 6
  • I just tested this and it works just fine on my Android device https://snack.expo.dev/@jsamr/stack-overflow-70390497 – Jules Sam. Randolph Dec 21 '21 at 11:48
  • Can you be more specific on the conditions for reproduction? Which platform / version of the later? – Jules Sam. Randolph Dec 21 '21 at 11:48
  • I've updated the question with the platform and devices where I've tested the bundle (Windows 10 Pro and Redmi Note 7 with Android 9 and Redmi 9C with Android 10). I've test your snack on these devices and it works. I've also generated an apk for my code that crashes on Expo Go and it worked on the mentioned devices – pferriol Dec 22 '21 at 12:03
  • OK; at that point, I would recommend you share a full reproduction via a git repository (since expo snack is not sufficient). The issue likely lies either in the build chain, or in the resolution of specific dependencies. – Jules Sam. Randolph Dec 22 '21 at 17:10
  • I've uploaded the code at https://github.com/pferriol/testRNRenderHtml I'll be out of the office until 10th of january so I probably won't be able to connect until then. – pferriol Dec 23 '21 at 13:41
  • I could not reproduce the issue from MacOS (I don't have access to Windows from where I am working, unfortunately). I have noticed that your `package-lock.json` is pre-v8 (npm-wise), a bit old. Furthermore, I would suggest getting the latest LTS Node + NPM installed on your system, delete the lock file, try a clean `npm install` and see what happens. You can also try updating the globally-installed expo cli package to its latest version. – Jules Sam. Randolph Dec 23 '21 at 16:27
  • 1
    Thanks @JulesSam.Randolph I followed your suggestion and it worked. – pferriol Jan 18 '22 at 08:04

1 Answers1

0

As Jules Sam. commented I was using a bit old version of Node, following his suggestions I have updated the libraries and it has worked.

Initial versions:

  • node: 14.2.0
  • npm: 6.14.4
  • expo-cli: 4.12.11

Final versions:

  • node: 16.13.2
  • npm: 8.1.2
  • expo-cli: 5.0.3

I followed this steps:

  1. Install new node version using nvm-windows
  2. Delete package-lock.json
  3. Delete node-modules folder
  4. Install globally last version of expo-cli
  5. Run npm install
pferriol
  • 11
  • 6