简体   繁体   English

React native - Function 调用不执行任何操作

[英]React native - Function call doesn't do anything

Very new to react native and javascript... I am trying to call a function and it doesn't seem to do anything.非常新的反应本机和 javascript ...我正在尝试调用 function,它似乎没有做任何事情。

Here is the fragment of code where the function is called:这是调用 function 的代码片段:

<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>

and there is the function I want to call:我想拨打 function:

const renderButtons = () => {
   return (
      <TouchableOpacity style={styles.interest_button} onPress={SettingsHandler}>
         <Text>{"  testsmartsmart  "}</Text>
      </TouchableOpacity>
   );
}

Only the container "testdumdum" appears, and I don't know why since the function does basically the same thing for now.只出现容器“testdumdum”,我不知道为什么,因为 function 现在基本上做同样的事情。

What should I do to fix this?我应该怎么做才能解决这个问题?

You need to start your component with a capital letter:您需要以大写字母开头您的组件:

Note: Always start component names with a capital letter.注意:组件名称始终以大写字母开头。

docs 文档

so change renderButtons to RenderButtons所以将renderButtons更改为RenderButtons

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM