1

So what i'm trying to do is when someone clicks an option I want to send two arguments during the onChange invocation. How can I manage to send the event and a second argument? I can think of a way to solve this problem that wouldn't require me to send the second argument, but I want to know if there is anyway I can send the event and another argument.

      {this.state.watchedMovies.map((movie, index) => (
          <div className="txn-row" key={index}>
                <div className="txn-data">{movie.moviename}</div>

                <div className="txn-data">
                    <select className="scorebar" onChange={() => this.changescore(event, movie)}>
                    <option>{movie.score > 10 ? <span>Rate</span> : movie.score}</option>
                    {this.state.grades.map((grade, index) =>(
                        <option value={grade} key={index}>{grade}</option>
                    ))}
                    </select>
                </div>

          </div>
      ))}
2
  • 2
    You have to write onChange={(event) => this.changescore(event, movie)} if you want to pass the event and the movie object to your onChange handler. Commented Aug 8, 2018 at 23:53
  • onChange={this.changescore.bind(null, movie)} Commented Aug 8, 2018 at 23:56

1 Answer 1

2

The function given to onChange will be invoked with the event as first argument, so you need to pass that along to your changescore method.

<select
  className="scorebar"
  onChange={(event) => this.changescore(event, movie)}
>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.