I am currently learning reactjs so I decided to build a react to-do list, am trying to toggle the display of a component but keep running into errors. Please what is the best way to toggle the display of the Action component when the user clicks on the icon with the class ‘ri-menu-line’? This is my snippet.My Code snippet
I tried using react useRef to toggle between an empty string and a className and pass it as a prop to the Action component and then, in the Action component add the prop to the section classList but i keep running into huge errors.
2
Answers
Try doing this:
Toggle state to true/false.
Use && to display or hide component. see https://beta.reactjs.org/learn/conditional-rendering