React native - 函数调用不做任何事情
React native - Function call doesn't do anything
对本机反应非常陌生,javascript...
我正在尝试调用一个函数,但它似乎没有执行任何操作。
这是调用该函数的代码片段:
<View style={styles.rows}>
<renderButtons/> //the function I want to call
<TouchableOpacity style={styles.interest_button} onPress={SettingsHandler}>
<Text>{" testdumdum "}</Text>
</TouchableOpacity> //test to ensure nothing is wrong w function itself
</View>
还有我要调用的函数:
const renderButtons = () => {
return (
<TouchableOpacity style={styles.interest_button} onPress={SettingsHandler}>
<Text>{" testsmartsmart "}</Text>
</TouchableOpacity>
);
}
只出现容器“testdumdum”,我不知道为什么,因为函数现在基本上做同样的事情。
我应该怎么做才能解决这个问题?
您的组件需要以大写字母开头:
Note: Always start component names with a capital letter.
所以将 renderButtons 更改为 RenderButtons
对本机反应非常陌生,javascript... 我正在尝试调用一个函数,但它似乎没有执行任何操作。
这是调用该函数的代码片段:
<View style={styles.rows}>
<renderButtons/> //the function I want to call
<TouchableOpacity style={styles.interest_button} onPress={SettingsHandler}>
<Text>{" testdumdum "}</Text>
</TouchableOpacity> //test to ensure nothing is wrong w function itself
</View>
还有我要调用的函数:
const renderButtons = () => {
return (
<TouchableOpacity style={styles.interest_button} onPress={SettingsHandler}>
<Text>{" testsmartsmart "}</Text>
</TouchableOpacity>
);
}
只出现容器“testdumdum”,我不知道为什么,因为函数现在基本上做同样的事情。
我应该怎么做才能解决这个问题?
您的组件需要以大写字母开头:
Note: Always start component names with a capital letter.
所以将 renderButtons 更改为 RenderButtons