This is because a classical if-else statement decides which lines of code to run, rather than which value to evaluate to. Blogs, forums, etc. Acidity of alcohols and basicity of amines. This experience made me realize that maybe other developers, maybe you, would appreciate a reminder of how you can render content without libraries. Theres more than one way to use conditional rendering in React. Consider these two components: We have a problem. The preference for opting new technology is to enjoy the benefit of latest improvements in the field. Some factors to include in your decision include your programming style, how complex the conditional logic is, and how comfortable you are with JavaScript, JSX, and advanced React concepts like HOCs. It loops over the array its called on (similar to Array.forEach()), and calls the supplied callback once for each item, passing the array element to it as an argument. Example: Get your own React.js Server We'll use these two components: function MissedGoal() { return <h1>MISSED!</h1>; } function MadeGoal() { return <h1>Goal!</h1>; } Ill make this required reading for my React students because even if they often go to React, understanding what a tool is doing for you enables you to better and more wisely use that tool. We could make this a little nicer by wrapping it in a function: Now whenever we load a new blog post, we can just call update() and it will appear. It adds a whole lot of lines for something that isnt that complicated, and it separates part of our rendering code from its place within the rest of the HTML. ), then an expression to execute if the condition is truthy followed by a colon (: ), and finally the expression to execute if the condition is falsy . Can you make reusable functions to make the code more straightforward and more reusable? How to Create and Update Lists in Vanilla JS | by Hajime - Medium Also remember that whenever conditions become too complex, it might be a good time to extract a component. The actual tutorial. After staring at the code with my pair programming partner, and with a huge help with from my technical coach, my technical coach guided us to look at our allKids function. Lets apply it to the example to see this in action. Start by creating a