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] Migrate from next12 pages to next13 app dir #145

Open
wants to merge 28 commits into
base: stable
Choose a base branch
from

Conversation

annaharr
Copy link
Contributor

  • Moved pages out of pages directory and into new next13 app directory

    • pages/index.js is now app/page.js
    • Head and app container from _app.js now is now in app/head.js and app/layout.js respectively
    • Note that all pages in app dir are server rendered unless "use client" is specified
  • Created a DataProvider

    • DataProvider now fetches data at 6 second intervals from s3 bucket
    • DataContextProvider wraps all app pages in app/layout.js
    • app/page.js and app/data/page.js get sample data from DataContext
  • Global styles moved from pages/global.css to styles/globals.css

@annaharr annaharr self-assigned this Feb 10, 2023
@annaharr annaharr changed the base branch from stable to next-13 February 10, 2023 15:55
Copy link
Contributor

@jedahan jedahan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great - i just put some small cleanup suggestions in the other PR to this PR

Comment on lines 18 to 69
// // import fetch from 'isomorphic-unfetch'

// // six seconds
// const updateTime = 6 * 60 * 1000

// const dataFetchParams = {
// method: 'GET',
// mode: 'cors',
// cache: 'no-cache',
// credentials: 'same-origin',
// headers: { 'Content-Type': 'application/json', 'Accept-Encoding': 'gzip' },
// // referrer: 'no-referrer'
// };

// export const fetchSamplesData = () =>
// fetch(ENDPOINTS.samples, dataFetchParams)
// .then((response) => {
// if (response.ok) return response.json();
// throw new Error(`Request rejected with status ${response.status}`);
// })
// .then((json) => {
// if (!json.version) return { samples: json };
// return json;
// });

// export const dataFetchProcess = (() => {
// let dataFetchProcess = null

// const fetching = update => () => {
// console.log('Fetching new data ...')
// fetchSamplesData().then(data => {
// console.log('New data received. Loading ...')
// console.log(data);
// update(data)
// })
// }

// const start = update => {
// if (dataFetchProcess === null) {
// console.log('Begining data fetching.')
// const fetcher = fetching(update)
// fetcher() // first instance
// dataFetchProcess = setInterval(fetcher, updateTime)
// } else {
// console.log('Data fetching already running.')
// }
// }

// const stop = () => { clearInterval(dataFetchProcess) }

// return { start, stop }
// })()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to delete

}
}, [setSamples, setUnits, setSources]);

useInterval(fetchData, 6000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets bump this to like 1-3 minutes, its unnecessarily responsive

Anna Harrington and others added 3 commits February 10, 2023 14:10
- 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

Co-authored-by: Amir Kaudinov <[email protected]>
@vercel
Copy link

vercel bot commented Feb 21, 2023

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

Name Status Preview Comments Updated
water ❌ Failed (Inspect) Feb 21, 2023 at 3:07PM (UTC)

Base automatically changed from next-13 to stable February 21, 2023 20:23
@AKaudinov AKaudinov changed the title Migrate from next12 pages to next13 app dir [DRAFT - experimental] Migrate from next12 pages to next13 app dir Mar 21, 2023
@AKaudinov
Copy link
Contributor

Keeping this PR open as an experimental draft of Next.js 13 experimental app directory

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.

3 participants