onClick function not calling a method

Joe

I have a React project where a component SubmitButton is rendered when the property isSelectedNumber change its state to true. The component SubmitButton, which is a button you can click, will call a method when the button is clicked by using the onClick function and that will lead to the property isSubmitClicked change to true that the component NextButton will render.

The thing is that just the SubmitButton is rendered and when I click the button of the component SubmitButton it doesn't render the component NextButton.

This the part of the wrapper component where both components will be rendered if the conditions are true.

{this.state.isSelectedNumber ?  <SubmitButton  handleClickSumbmit={this.handleClickSumbmit}/>  : null}
 {this.state.isSubmitClicked ?   <NextButton /> : null}

This is the part of the SubmitButton Component where the onClick function should call the handleCliclkSubmit method to change the property state:

 <button type="button" onClick={this.props.handleClickSubmit}></button>

This is the handleClickSubmit method:

    handleClickSumbmit () {
      this.setState({
        isSubmitClicked: true
      });
  }

I was wondering if you have any idea what could be happening and how to solve it.

Hemadri Dasari

You have typo error

Change

  <button type="button" onClick={this.props.handleClickSubmit}></button>

To

   <button type="button" onClick={this.props.handleClickSumbmit}></button>

Also the function name is not meaningful in your code. Change handleClickSumbmit to handleClickSubmit wherever you have handleClickSumbmit

Also since you are using regular function you have to bind it in constructor. I hope you already did that.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Calling a method to function a recyclerview from an onClick() of another recycler adapter class

From Dev

Calling a function onclick in Angular

From Dev

onclick is not calling function

From Dev

Calling a function onclick in Svelte

From Dev

Calling a function onclick in Svelte

From Dev

React useMemo with a onClick calling a method

From Dev

Calling a method on OnClick using TypeScript

From Dev

Onclick method in another onclick function

From Dev

Calling a javascript function on button onclick

From Dev

Function is not calling on onclick event in React

From Dev

Javascript - Calling a function for an onClick event

From Dev

HTML onClick attribute not calling function

From Dev

Calling a function onclick start and onclick stop

From Dev

How to pass a parameter to a filter method & calling the function in React onClick event with different params?

From Dev

Calling method onClick of Jsp form Jsp

From Dev

Calling method of another class on Onclick of AlertDialog

From Dev

ASP:Button tag is onclick method is not calling

From Android

Calling a function inside onRespons method

From Dev

About calling when there is a function in the method

From Dev

Calling function from setTimeout() method

From Dev

Calling a model method as property and not a function

From Dev

Calling a function from a class method

From Dev

Calling toString method in Main function

From Dev

Use of bind when calling a function on onClick Event

From Dev

Unity, Calling a IEnumerator function from Button onClick

From Dev

javascript change element background onclick calling function

From Java

Thymeleaf th:onclick event - calling confirm function

From Dev

Calling async function on javascript onclick (or any) events

From Dev

Calling function inside an onclick using Apps Script

Related Related

  1. 1

    Calling a method to function a recyclerview from an onClick() of another recycler adapter class

  2. 2

    Calling a function onclick in Angular

  3. 3

    onclick is not calling function

  4. 4

    Calling a function onclick in Svelte

  5. 5

    Calling a function onclick in Svelte

  6. 6

    React useMemo with a onClick calling a method

  7. 7

    Calling a method on OnClick using TypeScript

  8. 8

    Onclick method in another onclick function

  9. 9

    Calling a javascript function on button onclick

  10. 10

    Function is not calling on onclick event in React

  11. 11

    Javascript - Calling a function for an onClick event

  12. 12

    HTML onClick attribute not calling function

  13. 13

    Calling a function onclick start and onclick stop

  14. 14

    How to pass a parameter to a filter method & calling the function in React onClick event with different params?

  15. 15

    Calling method onClick of Jsp form Jsp

  16. 16

    Calling method of another class on Onclick of AlertDialog

  17. 17

    ASP:Button tag is onclick method is not calling

  18. 18

    Calling a function inside onRespons method

  19. 19

    About calling when there is a function in the method

  20. 20

    Calling function from setTimeout() method

  21. 21

    Calling a model method as property and not a function

  22. 22

    Calling a function from a class method

  23. 23

    Calling toString method in Main function

  24. 24

    Use of bind when calling a function on onClick Event

  25. 25

    Unity, Calling a IEnumerator function from Button onClick

  26. 26

    javascript change element background onclick calling function

  27. 27

    Thymeleaf th:onclick event - calling confirm function

  28. 28

    Calling async function on javascript onclick (or any) events

  29. 29

    Calling function inside an onclick using Apps Script

HotTag

Archive