Yogesh Chauhan's Blog

What are “holes” in a React component?

in React on May 27, 2021

To understand the holes in a component, you might want to read this first:

What does Containment mean in React?

Long story short, some generic “boxes” components like Sidebar or a Dialog box in React are not aware of their children ahead of time. In those cases, React recommends that those components use their special children props to pass the children elements into their output.

So, as we saw in the containment demo example, we are passing the contents as children props in another component. But you don’t need to do that every time.

Sometimes, you just want to pass them using your own different convention rather than just children props. That way you create holes in your react components.

Just like this example:

Sidebar and MainContents are objects so we can pass them just like we pass children props. React components are very flexible as you can pass almost anything to it.


Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 How to add Read More Read Less Button using JavaScript? #3 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface #Jan 14 How to display a student’s individual transcript in Colleague? #Jan 11 How to install PuTTY on a MacOS?
You might also like these
How to create a sticky menu pin using CSS?CSSHow to remove N/A from Radio Button list in Drupal?DrupalAdd animation to your skills bar using CSSCSSThe SELECT DISTINCT Statement in SQLSQL/MySQLFull and Partial CUBE in Postgres with ExamplesPostgresHow to change your WordPress database prefix?WordPressArray.from() Method in JavaScriptJavaScriptHow to check if the page is single post page in WordPress?WordPressObservation of Human Behavior [Shopping Observation Example]MiscellaneousA complete diagram with building blocks of an Angular applicationAngularHow to compress images with gulp in WordPress?WordPressWhat is React? Learn the basicsReact