Search code examples
iosreact-nativenavigatornavigator-ios

How to support react-native's string type in WebStorm?


I'm learning React-Native . I can find NavigatorIOS's demo (code) , I copy this code and write to webStorm , but webStorm throw Error .


This code :

_renderRow = (title: string, onPress: Function) => { // Error :'Types are not supported by current Javascript version !
    return (
        <View>
            <TouchableHighlight onPress={onPress}>
                <View style={styles.row}>
                    <Text style={styles.rowText}>
                        {title}
                    </Text>
                </View>
            </TouchableHighlight>
            <View style={styles.separator} />
        </View>
    );
};

Error code :_renderRow = (title: string, onPress: Function) =>{...}

Error description:

string :'Types are not supported by current Javascript version !

Function :'Types are not supported by current Javascript version !

My WebStorm's Javascript language version is React JSX

Question:

1、Why the WebStorm cannot support string type and Function type ? this code is react-native example with Facebook !

2、I don't understand why this code is not ES6 code , I'm a iOS programmer , please help me , thanks .


Solution

  • Javascript don't support typed function parameters, which is why you have errors there.

    I believe the reason you see that in the example is because they are using Flow