链接包含和使用 react-native-render-html 的 url 时出错
Error linking an url containing & using react-native-render-html
我正在尝试将 link 包含到外部 url 中,其中 key/value 对以 & 使用 react-native-render-html in an app developed with expo but when I run the code on Expo Go 客户端,我遇到了错误:
TypeError: undefined 不是对象(正在计算 'this.entityTrie[0]')
我正在使用:
- 世博会诉 43.0.2
- expo-cli v. 4.12.11
- Expo Go v. 2.22.3
- react-native-render-html v.6.3.1
我是 运行 expo-cli on Windows 10 Pro,我已经在 2 种不同的设备上测试了捆绑包:一台带有 Android 9 的 Redmi Note 7 和一台 Redmi 9C Android 10.
最令人不安的是,如果我使用 expo 生成 .apk 并将其安装在设备上,它就可以正常工作。
代码很简单:
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',
},
});
我尝试用 %26 替换 & 但它不起作用。
我已将代码上传到 this git 存储库。
有人知道我怎么解决吗?
谢谢
作为朱尔斯·萨姆。评论说我使用的是旧版本的 Node,按照他的建议我更新了库并且它已经工作了。
初始版本:
- 节点:14.2.0
- npm: 6.14.4
- expo-cli: 4.12.11
最终版本:
- 节点:16.13.2
- npm: 8.1.2
- expo-cli: 5.0.3
我遵循了以下步骤:
- 使用 nvm-windows
安装新节点版本
- 删除包-lock.json
- 删除节点模块文件夹
- 全局安装最新版本的 expo-cli
- 运行 npm 安装
我正在尝试将 link 包含到外部 url 中,其中 key/value 对以 & 使用 react-native-render-html in an app developed with expo but when I run the code on Expo Go 客户端,我遇到了错误:
TypeError: undefined 不是对象(正在计算 'this.entityTrie[0]')
我正在使用:
- 世博会诉 43.0.2
- expo-cli v. 4.12.11
- Expo Go v. 2.22.3
- react-native-render-html v.6.3.1
我是 运行 expo-cli on Windows 10 Pro,我已经在 2 种不同的设备上测试了捆绑包:一台带有 Android 9 的 Redmi Note 7 和一台 Redmi 9C Android 10.
最令人不安的是,如果我使用 expo 生成 .apk 并将其安装在设备上,它就可以正常工作。
代码很简单:
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',
},
});
我尝试用 %26 替换 & 但它不起作用。
我已将代码上传到 this git 存储库。
有人知道我怎么解决吗?
谢谢
作为朱尔斯·萨姆。评论说我使用的是旧版本的 Node,按照他的建议我更新了库并且它已经工作了。
初始版本:
- 节点:14.2.0
- npm: 6.14.4
- expo-cli: 4.12.11
最终版本:
- 节点:16.13.2
- npm: 8.1.2
- expo-cli: 5.0.3
我遵循了以下步骤:
- 使用 nvm-windows 安装新节点版本
- 删除包-lock.json
- 删除节点模块文件夹
- 全局安装最新版本的 expo-cli
- 运行 npm 安装