【发布时间】:2018-10-21 02:02:51
【问题描述】:
我使用以下代码段创建了一个新按钮,但出现“java.lang.String cannot be cast to com.facebook.react.uimanager.AccessibilityDelegateUtil$AccessibilityRole”错误。我做了一些挖掘,似乎这是由于 React Native 0.57.3 不稳定导致的错误,所以我按照许多论坛帖子的建议降级到 0.57.1。但是错误仍然存在,所以如果您可以查看我的代码并给我建议,我将不胜感激。
我的代码:
import React, {Component} from 'react';
import {StyleSheet, Text, View} from 'react-native';
import FetchLocation from './components/FetchLocation';
export default class App extends React.Component{
getUserLocationHandler = () => {
}
render() {
return (
<View style={styles.container}>
<FetchLocation onGetLocation={this.getUserLocationHandler} />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
也是我的代码:
import React from 'react';
import { Button } from 'react-native';
const fetchLocation = props => {
return (
<Button title="Get Location" onPress={props.onGetLocation}/>
);
};
export default fetchLocation;
【问题讨论】:
-
错误出现在哪一行?
-
它没有明确说明,但为了方便起见,我编辑了错误图片。
标签: reactjs react-native error-handling compiler-errors react-redux