What cases does react portal have when there we have html dialog element?

149 Views Asked by At

After learning lit element (after react) for a bit, I’ve got a question: what use cases does react portal have when we have an html dialog element?

1

There are 1 best solutions below

0
Bogac On

I am not a React developer, but portals in web frameworks as a concept are for elements that need to be in a place under DOM tree other than the component they are defined in.

In that sense <dialog> elements are handling several use cases natively. So yes, if you need a dialog nowadays I'd go with <dialog> rather than using a portal.