反应本机获取错误-导航到其他屏幕抛出JSON NSMutableDictionary无法转换为NSString

时间:2018-06-29 06:19:33

标签: javascript ios react-native

我要导航至“所有屏幕”的主屏幕,但会引发错误

错误

  

[错误] [tid:main] [RCTConvert.m:58]错误设置属性   带有标签#1673的RCTView的'accessibilityLabel':JSON值'{               “ _owner” =“”;               “ _store” = {               };               key =“”;               道具= {                   可访问= 1;                   allowFontScaling = 1;                   儿童=(                                   {                           “ _owner” =“”;                           “ _store” = {                           };                           key =“”;                   ......                   ......                   ......                   };               };           }'类型的NSMutableDictionary无法转换为NSString

然后单击 dismiss(ESC)(关闭(ESC))。它会打开SeeAll屏幕并显示适当的内容。

那为什么会出现该错误以及如何解决它。

下面是我的代码

index.ios.js

export default class DemoClass extends Component {
    render() {
        const {navigation} = this.props;
        return (
            <AppNavigation navigation={navigation} />
        );
    }
}

Home.js

class Home extends Component {
    render() {
        return (
          <View style={styles.container}>
                <TouchableOpacity onPress={ () => {
                    navigation.navigate('SeeAll',{ title: 'SeeAllScreen' });
                }}>
                    <Text style={{marginVertical: 4, marginLeft: 12, marginRight: 4, color: 'white'}}>See All</Text>
                </TouchableOpacity>
          </View>
        );
    }

}

Home.navigationOptions = {
    title: <Text style={{fontWeight: 'bold',fontSize: 22}} numberOfLines={0}>
            <Text style={{color: '#FC2C43'}}>First</Text>
            <Text style={{color: '#FF7B32'}}>Screen</Text>
           </Text>
};

export default Home;

SeeAll.js

class SeeAll extends Component {
    constructor(props) {
      super(props);

      this.changeThisTitle(this.props.navigation.state.params.title);
    }

    changeThisTitle = (titleText) => {
        const {setParams} = this.props.navigation;
        setParams({ title: titleText })

    }

    static navigationOptions = ({ navigation }) => {
        const {state} = navigation;
        return {
            title: `${state.params.title}`,
        };
    };

    render() {
        return(
            <View style={styles.container}>
                <Text>Second Screen</Text>
            </View>
        );
    }
}
export default SeeAll;

0 个答案:

没有答案