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 How to uninstall Cocoapods from the Mac OS? #6 PHP Login System using PDO Part 1: Create User Registration Page

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
Content Blocks in SCSS (Sass)SCSSCan Firewall and IDPS Stop DDoS Attack?MiscellaneousHow to solve “framework not found” error in Swift?SwiftHow to concatenate variable with string in Swift?SwiftHow to get query string values in JavaScript? (URL Manipulation using URLSearchParams)JavaScriptGeneral concepts in DrupalDrupalHow to find the HCF or GCD and LCM of two given numbers using Swift?SwiftThe difference between isFinite() method and isFinite() function in JavaScriptJavaScriptAdd animated hamburgers menu using Hamburgers collection on GitHubCSSIntroduction to Angular modules Part 1: NgModule metadataAngularAggregate Functions Examples in Postgres for BeginnersPostgresHow to Recognize an Array in JavaScript?JavaScript