Lifecycle Hooks
Learn how lifecycle hooks can help us move the modal when the component is initialized.
We'll cover the following...
In the previous lesson, we saw how the modal could cause complications because it’s CSS properties can be affected by the parent component. The best way to combat this issue is to move the component to be a direct child of the <body>
element. We’ll want to do so with code.
It is possible to just manually move the component. However, we want to be able to drop the modal in any application. It would be a hassle to continually remember to load the component in the root most location in our application. It’s much more convenient if it’s able to move itself.
About lifecycle hooks
Before we move the element, we need to know when to move it. We want to move the ...