victory-native可以和expo一起使用吗?
Can victory-native be used with expo?
我正在玩 Victory Native chart library in an app where I'm using Expo。然而,我遇到了一些胜利组件导致应用程序崩溃的问题,例如<VictoryChart>
这对于使用该库非常重要。有谁知道是否可以使用 victory-native
with Expo?
我了解到 Expo 不允许使用 Victory Native 可能使用的原生元素?
这是我所做的:
exp init expo-victory-native-demo
cd expo-victory-native-demo
(来自here)
npm install --save victory-native react-native-svg
npm install
react-native link react-native-svg
然后我试玩了找到的演示 here,即将一些 Victory 组件放入 App.js,但是当我 运行 exp start
之后应用程序立即崩溃例如 <VictoryChart>
存在时启动,如果我只使用 <VictoryBar>
.
则不是问题
有一个将 Victory Native 与 Expo 结合使用的演示(请参阅 here),但我需要将其与现有的大型项目一起使用 Expo 并尝试在此演示之外使用 Victory Native 失败,如前所述多于。这也使用旧版本的 Expo 和 Victory Native。
为了完整起见,这是我的 App.js 崩溃了:
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { VictoryBar, VictoryChart, VictoryTheme } from "victory-native";
const data = [
{ quarter: 1, earnings: 13000 },
{ quarter: 2, earnings: 16500 },
{ quarter: 3, earnings: 14250 },
{ quarter: 4, earnings: 19000 }
];
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<VictoryChart width={350} theme={VictoryTheme.material}>
<VictoryBar data={data} x="quarter" y="earnings" />
</VictoryChart>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
移除 <VictoryChart>
后它不会崩溃:
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { VictoryBar, VictoryChart, VictoryTheme } from "victory-native";
const data = [
{ quarter: 1, earnings: 13000 },
{ quarter: 2, earnings: 16500 },
{ quarter: 3, earnings: 14250 },
{ quarter: 4, earnings: 19000 }
];
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<VictoryBar data={data} x="quarter" y="earnings" />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
这里是 package.json
:
{
"main": "node_modules/expo/AppEntry.js",
"private": true,
"dependencies": {
"expo": "^25.0.0",
"react": "16.2.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-25.0.0.tar.gz",
"react-native-svg": "^6.3.1",
"victory-native": "^0.17.2"
}
}
这个问题可能与 VictoryChart does not work with EXPO 23.0.0 有关。
通过执行以下操作解决了问题:
rm -rf node_modules/
- 从
package.json
中删除 react-native-svg
(参见 here)
npm install --save lodash
yarn install
然后在 exp start
之后我得到了以下信息:
App.js
看起来是这样的:
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { VictoryBar, VictoryChart, VictoryTheme } from "victory-native";
const data = [
{ quarter: 1, earnings: 13000 },
{ quarter: 2, earnings: 16500 },
{ quarter: 3, earnings: 14250 },
{ quarter: 4, earnings: 19000 }
];
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<VictoryChart width={350} theme={VictoryTheme.material}>
<VictoryBar data={data} x="quarter" y="earnings" />
</VictoryChart>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
和package.json
:
{
"main": "node_modules/expo/AppEntry.js",
"private": true,
"dependencies": {
"expo": "^25.0.0",
"lodash": "^4.17.5",
"react": "16.2.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-25.0.0.tar.gz",
"victory-native": "^0.17.2"
}
}
我正在玩 Victory Native chart library in an app where I'm using Expo。然而,我遇到了一些胜利组件导致应用程序崩溃的问题,例如<VictoryChart>
这对于使用该库非常重要。有谁知道是否可以使用 victory-native
with Expo?
我了解到
这是我所做的:
exp init expo-victory-native-demo
cd expo-victory-native-demo
(来自here)npm install --save victory-native react-native-svg
npm install
react-native link react-native-svg
然后我试玩了找到的演示 here,即将一些 Victory 组件放入 App.js,但是当我 运行 exp start
之后应用程序立即崩溃例如 <VictoryChart>
存在时启动,如果我只使用 <VictoryBar>
.
有一个将 Victory Native 与 Expo 结合使用的演示(请参阅 here),但我需要将其与现有的大型项目一起使用 Expo 并尝试在此演示之外使用 Victory Native 失败,如前所述多于。这也使用旧版本的 Expo 和 Victory Native。
为了完整起见,这是我的 App.js 崩溃了:
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { VictoryBar, VictoryChart, VictoryTheme } from "victory-native";
const data = [
{ quarter: 1, earnings: 13000 },
{ quarter: 2, earnings: 16500 },
{ quarter: 3, earnings: 14250 },
{ quarter: 4, earnings: 19000 }
];
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<VictoryChart width={350} theme={VictoryTheme.material}>
<VictoryBar data={data} x="quarter" y="earnings" />
</VictoryChart>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
移除 <VictoryChart>
后它不会崩溃:
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { VictoryBar, VictoryChart, VictoryTheme } from "victory-native";
const data = [
{ quarter: 1, earnings: 13000 },
{ quarter: 2, earnings: 16500 },
{ quarter: 3, earnings: 14250 },
{ quarter: 4, earnings: 19000 }
];
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<VictoryBar data={data} x="quarter" y="earnings" />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
这里是 package.json
:
{
"main": "node_modules/expo/AppEntry.js",
"private": true,
"dependencies": {
"expo": "^25.0.0",
"react": "16.2.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-25.0.0.tar.gz",
"react-native-svg": "^6.3.1",
"victory-native": "^0.17.2"
}
}
这个问题可能与 VictoryChart does not work with EXPO 23.0.0 有关。
通过执行以下操作解决了问题:
rm -rf node_modules/
- 从
package.json
中删除react-native-svg
(参见 here) npm install --save lodash
yarn install
然后在 exp start
之后我得到了以下信息:
App.js
看起来是这样的:
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { VictoryBar, VictoryChart, VictoryTheme } from "victory-native";
const data = [
{ quarter: 1, earnings: 13000 },
{ quarter: 2, earnings: 16500 },
{ quarter: 3, earnings: 14250 },
{ quarter: 4, earnings: 19000 }
];
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<VictoryChart width={350} theme={VictoryTheme.material}>
<VictoryBar data={data} x="quarter" y="earnings" />
</VictoryChart>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
和package.json
:
{
"main": "node_modules/expo/AppEntry.js",
"private": true,
"dependencies": {
"expo": "^25.0.0",
"lodash": "^4.17.5",
"react": "16.2.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-25.0.0.tar.gz",
"victory-native": "^0.17.2"
}
}