pferriol
pferriol

Reputation: 11

Error linking an url containing & using react-native-render-html

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:

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

Upvotes: 0

Views: 598

Answers (1)

pferriol
pferriol

Reputation: 11

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

Upvotes: 0

Related Questions