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 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #2 How to add Read More Read Less Button using JavaScript? #3 How to check if radio button is checked or not using JavaScript? #4 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #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
You might also like these
Introduction to components and templates Part 4: Pipes and DirectivesAngularHow to send and receive query strings via links in Angular 9?AngularHow to check if the element exists using JavaScript and jQuery?JavaScriptCREATE TABLE Examples in PostgreSQLPostgresForcing the domain to serve securely using HTTPSMiscellaneousAdd animated hamburgers menu using Hamburgers collection on GitHubCSSAdvanced nesting in Sass (SCSS) using at-rootSCSSHow to zoom an element on hover using CSS?CSSWordPress: How to set WP_SITEURL?WordPressWhat is the difference between float and double?MiscellaneousPHP arrays for US states’ full names and abbreviationsPHPHow to create a circle that follows a cursor using JavaScript and CSS?CSS