#React.js
17 messages · Page 1 of 1 (latest)
Its navbar
When I will click on getUser
It fetches users
It works if I just add
<Struct/> to the app.js
but I want to make it an event listener function
seems like what Im fetching is "object"
And onClick={} seems to have some trouble with it
Is onclick supposed to render Struct when you click on the button?
Yea, it was a desperate method to solve the bug
Earlier I tried to pass the function as a prop
try to write that struct function before this image return. and then <button onClick={(e)=> YoureFunctionName()}>Please press here </button>
Realistically it would make sense to just use a Boolean which is used to determine whether the Struct component should be rendered
So you could just just set that to true on click
Yeah, conditional rendering makes more sense