Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT - experimental] Route grouping next.js 13 app dir #148

Open
wants to merge 11 commits into
base: next-13-app-dir
Choose a base branch
from

Conversation

AKaudinov
Copy link
Contributor

  • Set up a parent layout that fetches the data and wraps the app with the data provider
  • Set up child grouped routes:
    • index group / main page
      • so the layout can wrap the page with its specific container styles
    • other group / about and data pages
      • layout wraps the pages with a standard container
  • Added loading ui component to each grouping for when a route segment isn’t ready to render yet.
    • this works better and doesn't have an issue where a single parent loading ui sometimes just hangs when parent/child layout functionality is involved.
  • Fixed multiple hydration issues where certain components were being pre-rendered on the sever even though they were marked as use client

Amir Kaudinov added 9 commits February 10, 2023 14:35
- Created a new hook: useIsMobile
   - which executes on the client side
- Refactored DateRangePicker to a functional component so
  it can use the new `useIsMobile` hook when mounting
- Removed the usage of isMobile layout helper that was trying
  to access the window width directly on React hydration after
  server render, which caused different rendered content issues.
   - the new isMobile hook uses `useEffect` which fires after
     mount, preventing hydration mismatches
- Split the application into a root layout with grouped child layouts
  - refactored the previously grouped root layouts into child grouped
    layouts: one for index and the other one for all other pages
    that do not have a fixed container
  - the pages no longer fully refresh when navigating between the
    different routes
- Added `loading.js` to each grouped layout to avoid the root loading
  issue with suspense fallback continuing to render when route segment
  is ready
- Throttled the useIsMobile hook function
- Added a new throttled useWindowWidth hook
- Fixed an issue where the Carousel component was trying to access
  window width in a function on server side, causing hydration errors.
  the function now accepts window width from the component
- Updated the Navbar to check the route name and clicked link
  before closing on mobile viewports
@AKaudinov AKaudinov self-assigned this Feb 21, 2023
@vercel
Copy link

vercel bot commented Feb 21, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
water ✅ Ready (Inspect) Visit Preview Feb 21, 2023 at 5:34PM (UTC)

@AKaudinov AKaudinov changed the title Route grouping next.js 13 app dir [DRAFT - experimental] Route grouping next.js 13 app dir Mar 21, 2023
@AKaudinov
Copy link
Contributor Author

Keeping this PR open as an experimental draft of Next.js 13 experimental app directory with Route grouping.
PR is specifically pointed to the next-13-app-dir branch, as these changes would need to be merged into it, first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant