[DRAFT - experimental] Migrate from next12 pages to next13 app dir #145
Open
[DRAFT - experimental] Migrate from next12 pages to next13 app dir #145
Conversation
- Added a Disclaimer to the Data top bar - Updated the Data top bar styles to account for the disclaimer - Created disclaimer styles to be responsive
jedahan
approved these changes
Feb 10, 2023
Contributor
jedahan
left a comment
There was a problem hiding this comment.
This looks great - i just put some small cleanup suggestions in the other PR to this PR
helpers/dataLoader.js
Outdated
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 } | ||
| // })() |
providers/DataProvider.js
Outdated
| } | ||
| }, [setSamples, setUnits, setSources]); | ||
|
|
||
| useInterval(fetchData, 6000); |
Contributor
There was a problem hiding this comment.
lets bump this to like 1-3 minutes, its unnecessarily responsive
- 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 <amirkaudinov@R3060.local>
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Contributor
|
Keeping this PR open as an experimental draft of Next.js 13 experimental app directory |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moved pages out of pages directory and into new next13 app directory
Created a DataProvider
Global styles moved from pages/global.css to styles/globals.css