0
Generating a new component onClick in react
On click i want to generate a new joke which is in another component. Could someone tell me what i am missing. https://codesandbox.io/s/old-cache-gc32p?file=/src/App.js
5 Answers
+ 4
Dee I used that api to make an example , so you can see if this is something you were looking to do or not,
https://code.sololearn.com/WYSh4ohru9VF/?ref=app
+ 3
Event trigger function should not be used for create component Joke, use onClick to update state of joke instead. The state then can be passed to component though props.
https://code.sololearn.com/W3tRab01frMX/?ref=app
+ 1
onClick handler is expecting a function but you are passing an object to it , i.e. the one created using map function .
I am not even sure if you have the correct state setup as not every state needs to be mutated.
So it will be intersting for me to see what can you change to output what you want or you can just tell what exactly is your program suppose to do so i can try to re arrange it to make it work properly.
+ 1
Thank you Abhay and Calvin. This seem to answer my question, let me make them work.
0
I am using the chuck Norris Api. And i want to have a new joke everytime i click on a particular category based on that particular category. I was trying to simulate that before using the api