Loading tutorials
children, and use useState and useEffect. It also assumes you know what a DOM node is and that document.body is the root of the page's visible content. Portals depend on one idea: a React app maintains two separate3 min readchildren, and the useState and useEffect hooks. It also assumes you know that the DOM is a tree of nodes with document.body at the top. The previous chapters covered why clipped and buried UI happens and how the React tree dif2 min readuseState and useEffect, and the basics of the DOM and CSS stacking. You have already seen createPortal(children, container). Here you decide what container should be, and how to manage it safely.3 min readchildren, useState and useEffect, basic DOM concepts, and CSS positioning with z-index. A modal is the standard use case for createPortal, so this chapter builds one step by step.3 min readuseState and useEffect, and how DOM events bubble. It also assumes you have seen createPortal, which renders children into a different DOM node.3 min readcreatePortal, useContext, and useState. You should also know the difference between the React component tree and the DOM tree from earlier chapters. This chapter shows which behaviors follow each tree.2 min readuseState and useEffect, and that you have already built the basic portal modal from the previous chapter. A portal puts the dialog in the right place visually. It does nothing for keyboard users or screen readers. This chapter covers th3 min readcreatePortal, the modal pattern from the earlier chapters, and basic useRef, useState and useEffect usage. You should also know what position: fixed does and that getBoundingClientRect() returns an element's position relative to the viewport.3 min readuseState and useEffect, and the difference between the React tree and the DOM tree. It covers why createPortal fails during server rendering and how to make portal components safe.3 min readModal, ClientPortal and useEscapeKey examples from earlier chapters. The tests use @testing-library/jest-dom matchers such as toBeInTheDocument, and `@testing-library/user2 min readcreatePortal, the difference between the React tree and the DOM tree, and how events and context cross a portal. It collects the mistakes that show up most often in real projects and gives a checklist for avoiding them.3 min read