close

[Solved] Uncaught TypeError: this.props.updateInputValue is not a function

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Uncaught TypeError: this.props.updateInputValue is not a function in reactJs. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How To Solve Uncaught TypeError: this.props.updateInputValue is not a function Error ?

  1. How To Solve Uncaught TypeError: this.props.updateInputValue is not a function Error?

    To Solve Uncaught TypeError: this.props.updateInputValue is not a function Error Your child component only has the prop of updateInput as a method and you're calling this.props.updateInputValue() in the child component. Try to call them the same names.

  2. Uncaught TypeError: this.props.updateInputValue is not a function

    To Solve Uncaught TypeError: this.props.updateInputValue is not a function Error Your child component only has the prop of updateInput as a method and you're calling this.props.updateInputValue() in the child component. Try to call them the same names.

Solution 1

It should be

<WeatherForm
          updateInputValue={this.updateInputValue}
        />

Solution 2

Your child component only has the prop of updateInput as a method and you’re calling this.props.updateInputValue() in the child component. Try to call them the same names.

You’re also calling this.props.inputValue in the child component when you’re not passing inputValue into your child component as a prop.

What I would do to simplify the code and possible avoid mistakes like this in the future is to directly call this.props.updateInputValue in onChange event like this:onChange={e => this.props.updateInputValue(e)} You then save the work of binding another component method in the constructor. It’ll also make your unit testing easier but that’s another discussion.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read

Leave a Comment