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
The SQL EXISTS OperatorSQL/MySQLWordPress: How to query all posts from custom post type and display them in a list?WordPressHow to Pop an Alert Box in PHP?JavaScriptAND, OR and NOT boolean operators in Envision BasicEnvision BasicHow to create rotating texts using JavaScript and CSS?CSSThe basics of @import rule in SCSS (Sass)SCSSHow to change perception and behavior of a person for acceptance of new systems?MiscellaneousWhat is the correct way to enqueue multiple CSS files in WordPress?WordPressOptional arguments, Default parameters and REST parameters in JavaScriptJavaScriptLearn to Establish Connection using MySQLi (object-oriented), MySQLi (procedural) and PDO with Example CodePHPHow to create a flip pricing table using CSS and JavaScript?CSSThe substr() method in JavaScript and how it’s different from substring()JavaScript