I have a component with a close button in the corner. I've seen lots of great examples how to show and hide components using conditional rendering in the parent
parent.render (<>
...
{ this.displayState? <MyComponent/> : null }
...
</>)
I realise there are mulitple approaches to this but this is not the topic of the post. I can use this type of approach to toggle state from the parent but how do i toggle display/visibility state of a component from within itself. i.e. clicking its close button? Do I have to pass in a prop to the component to access parent displayState variable from within it? That seems very cumbersome.
This is a no-brainer in JQuery and Dom but I would like to know react way of doing it.
thanks