Reader small image

You're reading from  React Key Concepts

Product typeBook
Published inDec 2022
PublisherPackt
ISBN-139781803234502
Edition1st Edition
Right arrow
Author (1)
Maximilian Schwarzmüller
Maximilian Schwarzmüller
author image
Maximilian Schwarzmüller

Academind GmbH - Online Education: Bundling the courses and know-how of successful instructors, Academind strives to deliver high-quality online education. Online education, real-life success—that's what Academind stands for. Learn topics such as web development, data analysis, and more in a fun and engaging way. Maximilian Schwarzmüller: Since the age of 13, Maximilian Schwarzmüller has never stopped learning new programming skills and languages. In the early days, he started creating websites for friends and for fun. This passion has remained and shaped his decision to work as a freelance web developer and consultant. The success and fun he has in this job is immense and really keeps that passion alive. Although he started web development on the backend (PHP with Laravel and NodeJS), he has increasingly become a front-end developer using modern frameworks such as React, Angular, or VueJS 2 in a lot of projects. As a self-taught developer, he had broadened his horizon by studying business administration, resulting in a master's degree. This enabled him to work in a major strategy consultancy as well as a bank. Whilst learning and developing his skills, he realized that he enjoyed development more than these fields. As a self-taught professional, Max is familiar with the difficult topics when learning new or improving on already-known languages. This background and experience enables him to focus on the most relevant key concepts and topics. His track record is the best proof of that. Whether working as a development instructor or teaching business administration, he always receives great feedback. The most rewarding experience is to see how people find new and better jobs, build awesome web applications, acquire amazing projects, or simply enjoy their hobby with the help of his content.
Read more about Maximilian Schwarzmüller

Right arrow

React and Where Things End up in the DOM

Leaving the topic of refs, there is one other important React feature that can help with influencing (indirect) DOM interaction: Portals.

When building user interfaces, you sometimes need to display elements and content conditionally. This was already covered in Chapter 5, Rendering Lists and Conditional Content. When rendering conditional content, React will inject that content into the place in the DOM where the overall component (in which the conditional content is defined) is located.

For example, when showing a conditional error message below an input field, that error message is right below the input in the DOM:

Figure 7.4: The error message DOM element sits right below the <input> it belongs to

This behavior makes sense. Indeed, it would be pretty irritating if React were to start inserting DOM elements in random places. But in some scenarios, you may prefer a (conditional) DOM element to be inserted...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
React Key Concepts
Published in: Dec 2022Publisher: PacktISBN-13: 9781803234502

Author (1)

author image
Maximilian Schwarzmüller

Academind GmbH - Online Education: Bundling the courses and know-how of successful instructors, Academind strives to deliver high-quality online education. Online education, real-life success—that's what Academind stands for. Learn topics such as web development, data analysis, and more in a fun and engaging way. Maximilian Schwarzmüller: Since the age of 13, Maximilian Schwarzmüller has never stopped learning new programming skills and languages. In the early days, he started creating websites for friends and for fun. This passion has remained and shaped his decision to work as a freelance web developer and consultant. The success and fun he has in this job is immense and really keeps that passion alive. Although he started web development on the backend (PHP with Laravel and NodeJS), he has increasingly become a front-end developer using modern frameworks such as React, Angular, or VueJS 2 in a lot of projects. As a self-taught developer, he had broadened his horizon by studying business administration, resulting in a master's degree. This enabled him to work in a major strategy consultancy as well as a bank. Whilst learning and developing his skills, he realized that he enjoyed development more than these fields. As a self-taught professional, Max is familiar with the difficult topics when learning new or improving on already-known languages. This background and experience enables him to focus on the most relevant key concepts and topics. His track record is the best proof of that. Whether working as a development instructor or teaching business administration, he always receives great feedback. The most rewarding experience is to see how people find new and better jobs, build awesome web applications, acquire amazing projects, or simply enjoy their hobby with the help of his content.
Read more about Maximilian Schwarzmüller