Gatsby: [v2] Wrapping pages with layout causes CSS Transition issues

Created on 26 Jun 2018  路  3Comments  路  Source: gatsbyjs/gatsby

My v1 page features a cute little animation when navigating between pages. The animations are realized using react routers activeClassName and css transitions.

https://gyazo.com/3c89045a2bad1cda9f85cf3f32916d1f

This breaks when migrating to v2 according to the migration guide:

https://gyazo.com/4610bd9f7a19c65d4a9a0a4bf3a2548e

The reason is the following: In v2 the layout component gets unmounted and mounted every time I navigate from one page to another:

https://gyazo.com/ecd0e9543213bb12bb3a248fb2739042

This is because in v2 every page is individually wrapped with my layout component. On navigation the entire page, including its wrapper gets unmounted. In v1 the pages were being merely exchanged inside of layout.

The entire layout being remounted means that CSS does not consider the activeClassName to be applied to an existing element, instead a new element which happens to have this className appears. This means that the transition never fires.

Any idea if it is at all possible to avoid this?


See the page source code here: https://github.com/juliettepretot/juliette.sh

question or discussion

Most helpful comment

For posterity, I reported a similar issue here: https://github.com/gatsbyjs/gatsby/issues/6127

All 3 comments

+1
Would also strongly be interested in a solution to this!

For posterity, I reported a similar issue here: https://github.com/gatsbyjs/gatsby/issues/6127

Closing this in favour of #6127, so discussion is focussed to one issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

3CordGuy picture 3CordGuy  路  3Comments

brandonmp picture brandonmp  路  3Comments

KyleAMathews picture KyleAMathews  路  3Comments

ferMartz picture ferMartz  路  3Comments

signalwerk picture signalwerk  路  3Comments