Router: Why does Router render a div in the DOM?

Created on 8 May 2019  路  3Comments  路  Source: reach/router

You can see that in the examples:

<div tabindex="-1" role="group" style="outline: none;"><div><h2>Welcome</h2></div></div>

Why is that? This makes it harder to layout

Most helpful comment

The accessibility tools are not aware of the changing routes on SPA so it looses focus while transitioning. This library adds one more div wrapper that returns focus to the beginning of the page as it was refreshed. You can find similar solutions here https://github.com/ReactTraining/react-router/issues/5210

All 3 comments

The accessibility tools are not aware of the changing routes on SPA so it looses focus while transitioning. This library adds one more div wrapper that returns focus to the beginning of the page as it was refreshed. You can find similar solutions here https://github.com/ReactTraining/react-router/issues/5210

Ok, interesting!
Thank you for answering :)

If I understand the accessibility issue correctly, why would we ever need more than one of those extra DIV layers in our app? I am seeing one added for every nesting level in my routes. If I'm on a page that is nested 2 layers into my Router, I have 3 of those injected divs.

Screenshot from 2020-11-19 13-50-23

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benwiley4000 picture benwiley4000  路  4Comments

alexluong picture alexluong  路  3Comments

EJIqpEP picture EJIqpEP  路  4Comments

ricardobrandao picture ricardobrandao  路  5Comments

ryanflorence picture ryanflorence  路  4Comments