For some context, Im creating a color picker component. My app component has a function that deals with the click of one of the sample colors in the color picker component. Within the color picker component is an array of available colors which is mapped to buttons.
I keep receiving the error “TypeError: Cannot read property ‘props’ of undefined” which is created by my button code below.
I see your are referring to this.props. What does the entire function look like which contains the code above? Also, what does the component code look like which passes a prop named colorClock to this function?
It is always best if you can provide a link to your entire project code or at least the relevant components/functions. Otherwise, we are just guessing what the problem may be. Many people use Codepen.io to post their code or codesandbox.io.
I bet you have a reference error showing in your browser console, because you make a reference to this.props.colorClick in the onClick handler, but you are passing a prop named colorChange to the ColorPicker component.
Also, the error you say you are receiving above, what line of code does it reference in the error message? You really should post all your code. You will get better responses to help you.