Hello everyone ,
I am learning the master react course and I have an issue with passing a parameter to the arrow function! It’s shows the keyword not defined
How can I declare the parameter??
Thank you
Raghad
Hello everyone ,
I am learning the master react course and I have an issue with passing a parameter to the arrow function! It’s shows the keyword not defined
How can I declare the parameter??
Thank you
Raghad
Update: Removed curly braces and created JSfiddle example. (@Augustine_Awuori )
Can you show us a snippet of the source code and the error? However, here is a guess:
const myFunction = (myParameter) => console.log(myParameter);
myFunction("TestArgument");
Can you try and exclude the curly backets
You named the currentValue parameter of the callback supplied for map()
“movies
” so the “movie
” you pass to handleDelete()
in onClick
is undefined. I’d suggest to name the parameter “movie”.
Why did you change your handleDelete
function? The error was in the onClick
event.
@SAM is 100% right.
I think that part of the confusion here is with how the map method works. Remember, you want to use the ‘map’ method on a movies
object. But, why? Because movies
has an array (or group) of (single) movie
objects that we’d like to add HTML markup to. The map method makes this task easier to complete because it will iterate (repeat a set of instructions) through the movies
object and gives us a chance to mutate (change) each item in the array. How? We pass in an arrow function to the map method that will run on each movie
object.
I hope that clears things up. If not, lol, it’s part of the process. Believe me, this will get easier with practice. I’ve found myself stuck for hours on topics like this. However, it’s part of the process and an indication that you’re growing as a programmer. You’re pushing yourself beyond the limits of your knowledge. That’s commendable. If you’re stuck for a while longer, just watch Mosh’s solution and move on. Keep practicing, you’ll get another chance in the future to use the map method. I promise.
I found the mistake you just did. After mapping it should be singular of movie to be passed. In stead you used movies. Which is ok. But you’re not consistent. You used movie as an argument in your button instead of movies