# How do I toggle components in my react application

**URL:** <https://forum.freecodecamp.org/t/how-do-i-toggle-components-in-my-react-application/250136>\
**Category:** General\
**Created:** [January 8, 2019, 3:25pm UTC](https://forum.freecodecamp.org/t/how-do-i-toggle-components-in-my-react-application/250136 "2019-01-08T15:25:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tundeiness](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/tundeiness/32/42266_2.png) [@tundeiness](https://forum.freecodecamp.org/u/tundeiness)\
**Post date:** [January 8, 2019, 3:25pm UTC](https://forum.freecodecamp.org/t/how-do-i-toggle-components-in-my-react-application/250136/1 "2019-01-08T15:25:18Z")

</div>

So I have this project : [https://codepen.io/highness/pen/ebNYVX?editors=0010](https://codepen.io/highness/pen/ebNYVX?editors=0010)  
There is an Editor pane and a previewer pane. I want these pane to behave differently when a red dot (upper right) on the panes are clicked one at a time. I want it in such a way that if I click the red button on the upper right of the editor pane the previewer should be hidden and if I click the red button on the upper right of the previewer pane the editor should be hidden. So far what I have in the codepen is what I have so far. and it’s not working yet. Suggestions from other folks has not helped and besides I am new to react so it may take a while before I understand where anyone is driving at. However I am here for someone to help out and pull me along while explaining what I need to do. The link to the project is below:

> **[Markdown Previewer](https://codepen.io/highness/pen/ebNYVX?editors=0010)**
>
> ...

---

<div class="post-metadata">

**Author:** ![vipatron](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/vipatron/32/81984_2.png) [@vipatron](https://forum.freecodecamp.org/u/vipatron)\
**Post date:** [January 8, 2019, 3:56pm UTC](https://forum.freecodecamp.org/t/how-do-i-toggle-components-in-my-react-application/250136/2 "2019-01-08T15:56:09Z")

</div>

There are two ways to do this:

1. A general way (not specific to React): alter the CSS `display` property. You would need to conditionally change this value and then render the component with that CSS. (Not ideal for this situation, but it’s how you would “grey-out” an inactive component without making it disappear.)
2. A React-specific way: do or do not render a component on the basis of props or (as in your case,) state.

This was covered in the curriculum, but it’s more like a textbook - read once, and come back to it many times as you actually work the problems: (From the React section):

 ![Capture](https://global.discourse-cdn.com/freecodecamp/original/3X/3/6/36d557255b0340cb727ff98e18358175ec4526e0.png)

I’d recommend [re-reading at least the first four sections](https://learn.freecodecamp.org/front-end-libraries/react/use-advanced-javascript-in-react-render-method), and then pick which of the three ways of conditional rendering you prefer for this situation. I’m an old-school programmer first blooded on C, so I love boolean logic, and would use the second way (AND), but since they are all semantically equivalent, pick the syntax that works for your brain.

---

<div class="post-metadata">

**Author:** ![tundeiness](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/tundeiness/32/42266_2.png) [@tundeiness](https://forum.freecodecamp.org/u/tundeiness)\
**Post date:** [January 8, 2019, 4:40pm UTC](https://forum.freecodecamp.org/t/how-do-i-toggle-components-in-my-react-application/250136/3 "2019-01-08T16:40:41Z")

</div>

Thanks. I have already resolved to go back to the curriculum but I’m kinda confused on what I need to focus. But now that I have it I will gladly check it out asap.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 8:06pm UTC](https://forum.freecodecamp.org/t/how-do-i-toggle-components-in-my-react-application/250136/4 "2021-01-17T20:06:28Z")

</div>

Closed on January 17, 2021, 8:06pm UTC


