ART库在本机反应中不起作用

时间:2018-11-14 14:29:55

标签: android react-native

我尝试在Android手机的react-native版本中使用ART库,但是无论我在Shape中放置什么,都无法渲染黑色图像,如下所示: enter image description here

我的代码:

import React from 'react';
import {
ART,
StyleSheet,
View,
Button,
} from 'react-native';

const {
Group,
Shape,
Surface,
} = ART;


export default class App extends React.Component {
    render() {
        return (
        <View style={styles.container}>
            <Surface width={500} height={500}>
                <Group x={0} y={0}>
                    <Shape
                      d="M10 80 C 40 10, 65 10, 95 80 S 150 150, 180 80"
                      stroke="#555"
                      strokeWidth={1}
                     />
                </Group>
            </Surface>
        </View>
        );
    }
}

2 个答案:

答案 0 :(得分:0)

React Native中的ART库不能很好地支持Android。有很多问题。以下是我认为可以很好地链接到您的示例:

https://github.com/facebook/react-native/issues/17565

https://github.com/facebook/react-native/issues/17565#issuecomment-430897843

我会说尝试上面链接中的一些解决方案。希望这会有所帮助!

答案 1 :(得分:0)

react-native-circular-progress中的appState解决方案对我有用。在初始屏幕上加载ART时确实出现了问题。在那种情况下,在appState处理程序中两次调用setState似乎可以解决问题。

_handleAppStateChange = (nextAppState) => {
    this.setState({ appState: 'random_value' });
    this.setState({ appState: nextAppState });
}
相关问题