Skip to content

Commit

Permalink
Merge branch 'canary' into feature/return-img
Browse files Browse the repository at this point in the history
  • Loading branch information
cvbuelow committed Sep 8, 2022
2 parents f426e1c + 2b9268a commit 5eb0f06
Show file tree
Hide file tree
Showing 72 changed files with 471 additions and 602 deletions.
3 changes: 0 additions & 3 deletions examples/custom-server-typescript/.babelrc

This file was deleted.

18 changes: 9 additions & 9 deletions examples/custom-server-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"start": "cross-env NODE_ENV=production node dist/index.js"
},
"dependencies": {
"cross-env": "^7.0.2",
"cross-env": "^7.0.3",
"next": "latest",
"react": "^17.0.2",
"react-dom": "^17.0.2"
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/node": "^12.0.12",
"@types/react": "^16.9.44",
"@types/react-dom": "^16.9.8",
"nodemon": "^2.0.4",
"ts-node": "^8.10.2",
"typescript": "4.0"
"@types/node": "^18.7.15",
"@types/react": "^18.0.18",
"@types/react-dom": "^18.0.6",
"nodemon": "^2.0.19",
"ts-node": "^10.9.1",
"typescript": "~4.8.2"
}
}
3 changes: 2 additions & 1 deletion examples/custom-server-typescript/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"preserveConstEnums": true,
"sourceMap": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true
"resolveJsonModule": true,
"incremental": true
},
"exclude": ["dist", ".next", "out", "next.config.js"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
Expand Down
2 changes: 1 addition & 1 deletion examples/react-remove-properties/next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @type {import('next').NextConfig} */
module.exports = {
experimental: {
compiler: {
reactRemoveProperties: true,
// Or, specify a custom list of regular expressions to match properties to remove.
// The regexes defined here are processed in Rust so the syntax is different from
Expand Down
7 changes: 5 additions & 2 deletions examples/using-preact/next.config.js
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)
20 changes: 12 additions & 8 deletions examples/using-preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
"build": "next build",
"start": "next start"
},
"devDependencies": {},
"dependencies": {
"next": "^12.0.0",
"next-plugin-preact": "^3.0.6",
"preact": "^10.5.15",
"preact-render-to-string": "^5.1.19",
"react": "npm:@preact/compat@^17.0.2",
"react-dom": "npm:@preact/compat@^17.0.2",
"react-ssr-prepass": "npm:preact-ssr-prepass@^1.2.0"
"next": "latest",
"next-plugin-preact": "latest",
"preact": "^10.10.6",
"preact-render-to-string": "^5.2.3",
"react": "npm:@preact/compat@^17.1.1",
"react-dom": "npm:@preact/compat@^17.1.1",
"react-ssr-prepass": "npm:preact-ssr-prepass@1.2.0"
},
"devDependencies": {
"@types/node": "18.7.15",
"@types/react": "16.9.17",
"typescript": "4.8.2"
}
}
3 changes: 0 additions & 3 deletions examples/using-preact/pages/about.js

This file was deleted.

3 changes: 3 additions & 0 deletions examples/using-preact/pages/about.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function AboutPage() {
return <div>About us</div>
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Link from 'next/link'

export default function Home() {
export default function IndexPage() {
return (
<div>
Hello World.{' '}
Expand Down
9 changes: 0 additions & 9 deletions examples/using-preact/pages/ssg.js

This file was deleted.

13 changes: 13 additions & 0 deletions examples/using-preact/pages/ssg.tsx
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>
}
9 changes: 0 additions & 9 deletions examples/using-preact/pages/ssr.js

This file was deleted.

13 changes: 13 additions & 0 deletions examples/using-preact/pages/ssr.tsx
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>
}
22 changes: 22 additions & 0 deletions examples/using-preact/tsconfig.json
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"]
}
4 changes: 0 additions & 4 deletions examples/with-mobx-state-tree-typescript/.babelrc

This file was deleted.

36 changes: 0 additions & 36 deletions examples/with-mobx-state-tree-typescript/.gitignore

This file was deleted.

34 changes: 1 addition & 33 deletions examples/with-mobx-state-tree-typescript/README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,3 @@
# MobX State Tree with TypeScript example

Usually splitting your app state into `pages` feels natural but sometimes you'll want to have global state for your app. This is an example on how you can use mobx that also works with our universal rendering approach.

In this example we are going to display a digital clock that updates every second. The first render is happening in the server and the date will be `00:00:00`, then the browser will take over and it will start updating the date.

To illustrate SSG and SSR, go to `/ssg` and `/ssr`, those pages are using Next.js data fetching methods to get the date in the server and return it as props to the page, and then the browser will hydrate the store and continue updating the date.

The trick here for supporting universal mobx is to separate the cases for the client and the server. When we are on the server we want to create a new store every time, otherwise different users data will be mixed up. If we are in the client we want to use always the same store. That's what we accomplish on `store.js`

The clock, under `components/Clock.js`, has access to the state using the `inject` and `observer` functions from `mobx-react`. In this case Clock is a direct child from the page but it could be deep down the render tree.

## Deploy your own

Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example) or preview live with [StackBlitz](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/with-mobx-state-tree-typescript)

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-mobx-state-tree-typescript&project-name=with-mobx-state-tree-typescript&repository-name=with-mobx-state-tree-typescript)

## How to use

Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init), [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/), or [pnpm](https://pnpm.io) to bootstrap the example:

```bash
npx create-next-app --example with-mobx-state-tree-typescript with-mobx-state-tree-typescript-app
```

```bash
yarn create next-app --example with-mobx-state-tree-typescript with-mobx-state-tree-typescript-app
```

```bash
pnpm create next-app --example with-mobx-state-tree-typescript with-mobx-state-tree-typescript-app
```

Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).
**Note:** This example has been moved to [examples/with-mobx-state-tree](../with-mobx-state-tree/)
5 changes: 0 additions & 5 deletions examples/with-mobx-state-tree-typescript/next-env.d.ts

This file was deleted.

24 changes: 0 additions & 24 deletions examples/with-mobx-state-tree-typescript/package.json

This file was deleted.

4 changes: 0 additions & 4 deletions examples/with-mobx-state-tree/.babelrc

This file was deleted.

12 changes: 6 additions & 6 deletions examples/with-mobx-state-tree/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# MobX State Tree example
# MobX State Tree with TypeScript example

Usually splitting your app state into `pages` feels natural but sometimes you'll want to have global state for your app. This is an example on how you can use mobx that also works with our universal rendering approach.

Expand All @@ -12,24 +12,24 @@ The clock, under `components/Clock.js`, has access to the state using the `injec

## Deploy your own

Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example) or preview live with [StackBlitz](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/with-mobx-state-tree)
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example) or preview live with [StackBlitz](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/with-mobx-state-tree-typescript)

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-mobx-state-tree&project-name=with-mobx-state-tree&repository-name=with-mobx-state-tree)
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/with-mobx-state-tree-typescript&project-name=with-mobx-state-tree-typescript&repository-name=with-mobx-state-tree-typescript)

## How to use

Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init), [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/), or [pnpm](https://pnpm.io) to bootstrap the example:

```bash
npx create-next-app --example with-mobx-state-tree with-mobx-state-tree-app
npx create-next-app --example with-mobx-state-tree-typescript with-mobx-state-tree-typescript-app
```

```bash
yarn create next-app --example with-mobx-state-tree with-mobx-state-tree-app
yarn create next-app --example with-mobx-state-tree-typescript with-mobx-state-tree-typescript-app
```

```bash
pnpm create next-app --example with-mobx-state-tree with-mobx-state-tree-app
pnpm create next-app --example with-mobx-state-tree-typescript with-mobx-state-tree-typescript-app
```

Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).
25 changes: 0 additions & 25 deletions examples/with-mobx-state-tree/components/Clock.js

This file was deleted.

35 changes: 0 additions & 35 deletions examples/with-mobx-state-tree/components/SampleComponent.js

This file was deleted.

0 comments on commit 5eb0f06

Please sign in to comment.