-
Notifications
You must be signed in to change notification settings - Fork 26.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'canary' into feat/configurable-dynamic-guards
- Loading branch information
Showing
57 changed files
with
582 additions
and
138 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
const withPreact = require('next-plugin-preact') | ||
|
||
module.exports = withPreact({ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
/* regular next.js config options here */ | ||
}) | ||
} | ||
|
||
module.exports = withPreact(nextConfig) |
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function AboutPage() { | ||
return <div>About us</div> | ||
} |
2 changes: 1 addition & 1 deletion
2
examples/using-preact/pages/index.js → examples/using-preact/pages/index.tsx
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { InferGetStaticPropsType } from 'next' | ||
|
||
export function getStaticProps() { | ||
return { | ||
props: { framework: 'preact' }, | ||
} | ||
} | ||
|
||
export default function SSGPage({ | ||
framework, | ||
}: InferGetStaticPropsType<typeof getStaticProps>) { | ||
return <div>{framework} ssg example</div> | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { InferGetServerSidePropsType } from 'next' | ||
|
||
export function getServerSideProps() { | ||
return { | ||
props: { framework: 'preact' }, | ||
} | ||
} | ||
|
||
export default function SSRPage({ | ||
framework, | ||
}: InferGetServerSidePropsType<typeof getServerSideProps>) { | ||
return <div>{framework} ssr example</div> | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": ["dom", "dom.iterable", "esnext"], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmit": true, | ||
"incremental": true, | ||
"esModuleInterop": true, | ||
"moduleResolution": "node", | ||
"module": "esnext", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"jsx": "preserve", | ||
"jsxFactory": "h", | ||
"jsxFragmentFactory": "Fragment" | ||
}, | ||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], | ||
"exclude": ["node_modules"] | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { | ||
useReducer, | ||
useContext, | ||
createContext, | ||
ReactNode, | ||
Dispatch, | ||
} from 'react' | ||
|
||
type CounterState = number | ||
type CounterAction = | ||
| { | ||
type: 'INCREASE' | 'DECREASE' | ||
} | ||
| { | ||
type: 'INCREASE_BY' | ||
payload: number | ||
} | ||
|
||
const CounterStateContext = createContext<CounterState>(0) | ||
const CounterDispatchContext = createContext<Dispatch<CounterAction>>( | ||
() => null | ||
) | ||
|
||
const reducer = (state: CounterState, action: CounterAction) => { | ||
switch (action.type) { | ||
case 'INCREASE': | ||
return state + 1 | ||
case 'DECREASE': | ||
return state - 1 | ||
case 'INCREASE_BY': | ||
return state + action.payload | ||
default: | ||
throw new Error(`Unknown action: ${JSON.stringify(action)}`) | ||
} | ||
} | ||
|
||
type CounterProviderProps = { | ||
children: ReactNode | ||
initialValue?: number | ||
} | ||
|
||
export const CounterProvider = ({ | ||
children, | ||
initialValue = 0, | ||
}: CounterProviderProps) => { | ||
const [state, dispatch] = useReducer(reducer, initialValue) | ||
return ( | ||
<CounterDispatchContext.Provider value={dispatch}> | ||
<CounterStateContext.Provider value={state}> | ||
{children} | ||
</CounterStateContext.Provider> | ||
</CounterDispatchContext.Provider> | ||
) | ||
} | ||
|
||
export const useCount = () => useContext(CounterStateContext) | ||
export const useDispatchCount = () => useContext(CounterDispatchContext) |
This file contains 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
5 changes: 2 additions & 3 deletions
5
examples/with-context-api/pages/_app.js → examples/with-context-api/pages/_app.tsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
import type { AppProps } from 'next/app' | ||
import { CounterProvider } from '../components/Counter' | ||
|
||
function MyApp({ Component, pageProps }) { | ||
export default function MyApp({ Component, pageProps }: AppProps) { | ||
return ( | ||
<CounterProvider> | ||
<Component {...pageProps} /> | ||
</CounterProvider> | ||
) | ||
} | ||
|
||
export default MyApp |
5 changes: 3 additions & 2 deletions
5
examples/with-context-api/pages/about.js → examples/with-context-api/pages/about.tsx
This file contains 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
5 changes: 3 additions & 2 deletions
5
examples/with-context-api/pages/index.js → examples/with-context-api/pages/index.tsx
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": ["dom", "dom.iterable", "esnext"], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmit": true, | ||
"incremental": true, | ||
"esModuleInterop": true, | ||
"moduleResolution": "node", | ||
"module": "esnext", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"jsx": "preserve" | ||
}, | ||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], | ||
"exclude": ["node_modules"] | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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
5 changes: 3 additions & 2 deletions
5
examples/with-react-jss/pages/_app.js → examples/with-react-jss/pages/_app.tsx
This file contains 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
4 changes: 2 additions & 2 deletions
4
examples/with-react-jss/pages/_document.js → examples/with-react-jss/pages/_document.tsx
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": ["dom", "dom.iterable", "esnext"], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmit": true, | ||
"incremental": true, | ||
"esModuleInterop": true, | ||
"moduleResolution": "node", | ||
"module": "esnext", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"jsx": "preserve" | ||
}, | ||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], | ||
"exclude": ["node_modules"] | ||
} |
Oops, something went wrong.