YogeshChauhan . com

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.

amazon

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 How to Use SQL MAX() Function with Dates? #6 PHP Login System using PDO Part 1: Create User Registration Page

Recently Posted

Jun 16 What are Stored Procedures for SQL Server? Jun 16 What are Class Constants in PHP? Jun 15 A short basic guide on states in React Jun 15 How to define constants in PHP? Jun 15 How to define visibility for a property in PHP? Jun 15 How to use @if and @else in SCSS?

You might also like these

How to retrieve homepage URL in WordPress?WordPressWhat’s Interpolation in SCSS (Sass)?SCSSHow to create a Progress Bar using JavaScript?JavaScriptCanvas Drawing in HTML5HTMLHow to detect the Blog Page in WordPress?WordPressThe actual difference between indexOf() and search() in JavaScriptJavaScriptHow to use a Subquery to Insert Multiple Rows in SQL Table?SQL/MySQLHow to position an image on top of another image using CSS?CSSSelector Lists and Combinators in SCSS (Sass)SCSSHow to change perception and behavior of a person for acceptance of new systems?MiscHow to embed YouTube or other video links in WordPress?WordPressHow to get Current Year, Month and Date in JavaScript?JavaScript