2

Very new to react native and javascript... I am trying to call a function and it doesn't seem to do anything.

Here is the fragment of code where the function is called:

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

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.

What should I do to fix this?

2
  • Hey, did you have time to try my suggestion? If it worked I would really appreciate it if you could accept my answer by pressing the check on the lefthand side of my answer. This also helps other people having the same issue who might stumble across your question.
    – m_wer
    Feb 28, 2022 at 7:39
  • 1
    Hi again! Yes it worked, sorry I didn't came back to this post to confirm. Still new to stack overflow and learning. Thanks a lot for your help!
    – Oreste
    Mar 1, 2022 at 12:38

1 Answer 1

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.