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 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #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

#Aug 15 Is PHP still good for back-end programming? #Aug 10 How to create a multisite network in WordPress? #Aug 3 How to create a circle that follows a cursor using JavaScript and CSS? #Aug 3 How to make a curtain slider using jQuery and CSS? #Aug 2 How to progressively load images and add a blurry placeholder? #Aug 1 How to create a placeholder loader (throbber) using CSS?
You might also like these
@mixin and @include in SCSS (Sass)SCSSclip and clip-path properties in CSSCSSWhat are partials in SCSS (Sass)?SCSSHow to import a CSS file using PHP code and not HTML code?PHPWordPress: How to find all posts from a custom post type with specific custom field?WordPressNumber Properties in JavaScriptJavaScriptHow to define visibility for a property in PHP?PHPA simple example on grid ‘auto-fill’ vs ‘auto-fit’CSSHow destructuring works in React?ReactHow to position an image on top of another image using CSS?CSSHow to scroll contents of HTML body horizontally and vertically using JavaScript?JavaScriptHow to send and receive query strings via links in Angular 9?Angular