1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
Commit graph

835 commits

Author SHA1 Message Date
Henri 98cf0a8311 [examples] Update react jss example (#6198)
This updates the react-jss example to work with the v10 alpha
2019-02-04 11:51:38 +01:00
Resi Respati 8fdb133903 [with-typescript] Improved intial props examples, added example detail (#6165)
I've just thought of a way to improve the initial props page by adding
an example for a list/detail page structure. To do that, I've created a
separate `/detail` page, and a mock API which calls data from the array
we made on the previous PR.

A ListDetail component is created as an example for displaying detail.

Page structure is also cleaned up. Should I go ahead and add an example
on how to style with styled-jsx + its TS declarations? I might decide to
do it within this week anyway.
2019-01-31 17:36:02 +00:00
Petr Messner 968475fb95 Update with-relay-modern and with-relay-modern-server-express (#6182)
Update examples with-relay-modern and with-relay-modern-server-express to react-relay 2.0.0

- react-relay has started to use new Context API instead of Legacy Context API
- add `parseInt` because graphql 14.0.0 introduced stricter scalar value coercion

Closes #6157
2019-01-31 10:38:19 +01:00
Timon Borter cf31021e25 Bugfix/redux saga 1 0 0 not ready (#6176)
This reverts the changes made in [this pr](https://github.com/zeit/next.js/pull/6109).
`redux-saga: "1.0.0"` changed the way it handles it's queues. Because of that we're still having trouble to implement the synchronous side-effects flow in `next-redux-saga`. See [this discussion](https://github.com/bbortt/next-redux-saga/pull/1) for more information.
Therefore I would feel more comfortable not to mislead users by giving them a non-working example in the main branch.
2019-01-30 15:34:18 +01:00
Jan Bejvl b8057edd6e Updated README.md with proper link (#6172)
Updated README.md with proper link to 'root-static-files' example.
2019-01-29 13:42:58 +01:00
Benjamin Hanes dbdd663921 Update with-react-native-web example to use babel (#6170)
Fixes https://github.com/zeit/next.js/issues/6138

Tested with both latest and 8.0.0-canary.17
2019-01-29 13:42:44 +01:00
Marcin Czenko 1475491568 Updates with-semantic-ui example (#6158)
I tried to make the example a bit more descriptive. I changed `publicPath` in `now.config.js` to be `/_next/static/`, in place of `./`, and `outputPath` to `static/` in place of `static/css/`.  The reason is that the webpack config will still fallback to `file-loader` for any content that is imported by the user and which is bigger that `8192` bytes. I think this content should not land in the css folder, which should probably stay css specific.

Moreover, for user content, like regular images, the former settings will fail.

If you have this:

```javascript
import LargeFile from './LargeFile.png'
```

it would be placed in `static/css/` but its url would resolve to `<base-url>/LargeFile.png`, which will fail. It works for semantic-ui alone, because `@zeit/next-css` will put the styles in `static/css/` and so `publicPath` of `./` would work just fine.

Putting assets in `static/` and setting `publicPath` to '/_next/static/' will resolve correctly for both semantic-ui related assets as well as for regular user assets.

I hope I am not mixing something up. I tested it locally and in serverless deployment, and this looks pretty consistent.
2019-01-28 08:37:24 +01:00
Timon Borter 7adb6c57f4 merge to redux-saga 1.0.0, api breaking changes included. (#6109)
Hi there
I noticed you have not yet included the api breaking changes in `"redux-saga": "1.0.0"`. Therefore I felt free to upgrade the dependencies in `examples/with-redux-saga`.
I do not know anything about apollo nor graphql, that is why I did not upgrade `examples/with-apollo-and-redux-saga`. But, I think you should do this on occasion.
Keep the great work up.
Regards
2019-01-25 22:25:08 +01:00
Resi Respati 6d41ed7e6f [with-typescript] Updated typescript and removed unused deps (#6116)
I've updated the TypeScript dependency to the latest version. Also
removed some dependencies that may not be needed.

I've also fixed tslint errors which may have appeared because of
previous updates to this starter kit, as well as added comments
to explain some parts of the code.
2019-01-24 10:18:43 +01:00
Lucas Feliciano ca521b36e6 Manually call sheet.seal() to avoid memory leaks on with-styled-components example (#6107)
I was noticing some bad memory leak on my company's application and I ended up finding this github issue ( https://github.com/styled-components/styled-components/issues/1624 ) .

This comment ( https://github.com/styled-components/styled-components/issues/1624#issuecomment-425382979 ) caught my attention, which lead to this other issue on the repository of styled components website ( https://github.com/styled-components/styled-components-website/issues/329 )

After applying the changes on my project I noticed a huge improvement on memory consumption.

So would be nice to update the example or start a discussion on how to solve this properly
2019-01-24 10:16:47 +01:00
Justin Noel d6ec10a4bf add new nextjs typings with samples (#6102)
The current `examples/with-typescript` is not using the latest type definitions currently available on DefinitelyTyped project for next.

Added new list page examples that demonstrate how to use the new Types for both stateless functional components and classes.  Also modified examples for list to demonstrate typings for `getInitialProps`.
2019-01-23 12:37:09 +01:00
Henri 02e44d13a9 [examples/react-jss] Add support for styled custom App component (#6094)
With the current example it's not possible to use any components with styles inside a custom App component.
 
Reference issue: cssinjs/jss#939
2019-01-20 14:41:49 +01:00
Matthias Wilhelm b0a469233b Close #5607 - Bug in examples/with-data-prefetch (#6093)
ctx.pathname was set to url including the query of the page to prefetch
therefore the page was cached with the wrong key (article%3Fid=1?id=1),
and that's why the cache didn't work (right key: article?id=1)
2019-01-20 13:41:49 +01:00
Gary Meehan b8c9a1b574 Add next-seo example (#6088)
This PR adds a basic example using [next-seo](https://www.npmjs.com/package/next-seo).
2019-01-19 13:07:13 +01:00
Gary Meehan 0786dbfb04 Update with-storybook example (#6089)
Updates to the latest version of Storybook.
2019-01-19 12:04:44 +01:00
James Mulholland 9f08e48d72 With segment (#6060)
RE: https://github.com/zeit/next.js/issues/4587, this pull request improves the with-segment example.

Previously, only SSR page loads were tracked. This pull request adds manual page view logging via `Router.events.on('routeChangeComplete')` in `Page.js`.

There is also a minor bug fix on the textarea to remove a console error.
2019-01-18 20:40:23 +01:00
Saro Vindigni c957c9d1a0 ADD user to docker-compose (#6085) 2019-01-18 12:03:48 +01:00
Peter Kellner 53f2d88566 Updated with-context-api to include an about page and also events that pass data to context provider (#6082)
…aces (home and about pages). This makes it the example more clear and why someone might want to use _app.js in the first place.  Also, added a button on the about page that allows for passing and arbitrary value from the about page to the context provider. I disagree with the naming convention of calling the class CounterProvider. It includes both a Provider and Consumer so it should have some name that covers both.  Maybe it should be called CounterContext but I did not change that. I've seen other examples of the same naming conversion so figure I'm the odd duck here (still think it's wrong no matter how many people do it).
2019-01-17 22:13:34 +01:00
Tim Neutkens 02ab732096
Remove next/asset (#6046)
* Remove next/asset

Reasoning described in #5970

* Remove next/asset tests

* Bring back asset-page
2019-01-14 01:32:20 +01:00
Peter Kellner 341fb9947b fixed spelling not to no (#6044)
small spelling correction
2019-01-13 22:26:21 +01:00
astenmies 68ceef68e1 Add multiple Editors example (#6031) 2019-01-11 13:48:46 +01:00
Jayden Seric eb24e6ffc6 Add an example with graphql-react (#5984)
Adds an example with [`graphql-react`](https://github.com/jaydenseric/graphql-react), using [`next-graphql-react`](https://github.com/jaydenseric/next-graphql-react).

[`graphql-react`](https://github.com/jaydenseric/graphql-react) is a lightweight but powerful [GraphQL](https://graphql.org) client for React; the first [Relay](https://facebook.github.io/relay) and [Apollo](https://apollographql.com/docs/react) alternative with server side rendering.
2019-01-09 10:24:38 +01:00
Peter Kellner 3a3347dc5f The current TypeScript "with-typescript" looks like it was put there as a place holder. I'm fairly new to TypeScript but I'm sure the changes I've made here will be a huge improvement. Open to suggestions and to update as appropriate. Also, Tried to run yarn lint --fix to no avail. I can't figure out how to get it to find lint whether I'm running on my mac or PC. I tried lots of variations around npm i lint -g but had no success. (#6011) 2019-01-08 22:29:58 +01:00
Zack Tanner f9b98e6cf7 SSR for styled-components babel plugin (fixes #5988) (#6001)
Enables SSR for styled-components babel-plugin to prevent HTML attribute mismatch warnings during rehydration.
2019-01-07 00:12:35 +01:00
Zack Tanner 22f9009816 remove decorator proposal plugin from ant example (fixes #5985) (#6002) 2019-01-07 00:11:16 +01:00
tylim 5d8ae4456e improve with-unstated example (#5998)
improve the example so that it can preserve unstated from server to client unstated
2019-01-06 16:58:06 +01:00
Juan Olvera 7e12997af6 Test updater script on examples folder (#5993)
I wrote a [script](https://github.com/j0lv3r4/dependency-version-updater) to update dependencies recursively in `package.json` files, e.g.:

```
$ node index.js --path="./examples" --dependencies="react=^16.7.0,react-dom=^16.7.0"
```

This PR contains the result against the examples folder.
2019-01-05 12:19:27 +01:00
Juan Olvera 89a4cabbd6 Change React version of examples to latest (#5990)
I changed the version to the following files:

- [x] - examples/with-next-css/package.json
- [x] - examples/with-draft-js/package.json
- [x] - examples/custom-server-polka/package.json
- [x] - examples/with-cerebral/package.json
- [x] - examples/with-zones/package.json
- [x] - examples/with-universal-configuration-runtime/package.json
- [x] - examples/with-apollo/package.json
- [x] - examples/with-higher-order-component/package.json
- [x] - examples/with-hashed-statics/package.json
- [x] - examples/with-pkg/package.json
- [x] - examples/with-jest/package.json
- [x] - examples/with-glamorous/package.json
- [x] - examples/with-custom-reverse-proxy/package.json
- [ ] - examples/with-emotion/package.json
- [x] - examples/with-styled-jsx-scss/package.json
- [x] - examples/with-styled-jsx-plugins/package.json

`with-emotion/package.json` already has the latest, so I guess it's other packabe. BUT I think we need to update this example with the latest version of `emotion` since it changed a little bit (for better).
2019-01-05 12:16:07 +01:00
Dima e3499553c4 unnecessary prop store in getInitialProps (#5983) 2019-01-02 21:39:38 +01:00
Niklas Wagner 85fd832ed8 Fix rtl-test example & add Snapshot testing (#5981) 2019-01-02 16:28:40 +01:00
Adam Lane c4b9e079bf Add example of getInitialProps to with-reasonml (#5975)
The current reasonml needs an example of how to do getInitialProps.  tmepple posted the only known way of doing it in [this comment](https://github.com/zeit/next.js/issues/4202#issuecomment-439175214).   It is unlikely reasonml users are going to discover that comment or figure it out on their own so having it in an example is critical. 

Also, dependencies updated.  After updating dependencies, I get this error:
```
ModuleBuildError: Module build failed (from ./node_modules/next/dist/build/webpack/loaders/next-babel-loader.js):
[1] Error: Cannot find module '@babel/core'
[1]  babel-loader@8 requires Babel 7.x (the package '@babel/core'). If you'd like to use Babel 6.x ('babel-core'), you should install 'babel-loader@7'.
```
Seems like @babel/core is required as peer dependency per [this comment](https://github.com/babel/gulp-babel/issues/124#issuecomment-326853222) so I added it.

The way to do getInitialProps has changed in 7.0.2 canary so this also has a comment in the code about what change is required to get that working.
2019-01-02 11:43:19 +01:00
Rafael Mariano 75efa817c0 Modify with-universal-configuration example (#4498) (#5948)
Explains in details how the "with-universal-configuration" example works and rename it to "with-universal-configuration-build-time". Changing the example name makes the purpose of the example clear.

The "env-config.js" file introduce one more sample of variable usage that instantiates an immediate value of the local environment variable. This makes it even clearer how build-time variable configuration works. The "index.js" page makes explicit the use of these configured environment variables.

The universal configuration confusion happens when the value of the environment variable is used directly in the application causing an effect in server-side but not on the client side.
2018-12-26 20:19:31 +01:00
Steven Bell 05479400e3 Update react and react-dom to use "latest" (#5942) 2018-12-24 11:24:25 +01:00
Jean bdfa37cd4d Add react-testing-library example (#5940)
This example show how you can test Next.js apps with [react-testing-library](https://github.com/kentcdodds/react-testing-library).

This library encourages your applications to be more accessible and allows you to get your tests closer to using your components the way a user will, which allows your tests to give you more confidence that your application will work when a real user uses it. And also, is a replacement for enzyme.

<img width="733" alt="Image showing the words next.js + react testing library" src="https://user-images.githubusercontent.com/4689228/50387208-40223200-06de-11e9-9358-607092eb25a0.png">
2018-12-23 23:23:16 +01:00
Zack Tanner ec33b83843 Fix with-jest-typescript example to keep babel-jest in sync with jest (#5941)
This fixes the `with-jest-typescript` example to keep jest in sync with babel-jest (also updated to the latest of both). Having them resolve to different versions was resulting in weird errors.

When attempting to update the `transform` property in `jest.setup.js` to add babel-jest support to *.js/jsx files, it would throw:

> Plugin 0 specified in "node_modules/next/babel.js" provided an invalid property of "default" (While processing preset: "node_modules/next/babel.js")

Indirectly, this will fix https://github.com/zeit/next.js/issues/5917, once the author updates `jest.setup.js` to have:
```js
  transform: {
    '^.+\\.(js|tsx)?$': 'babel-jest',
  },
```
2018-12-23 21:55:35 +01:00
Martin Alix b5fa6c5969 Corrects Typo from next-bundle-analyzer/readme.md (#5939)
c.f. https://github.com/zeit/next-plugins/blob/master/packages/next-bundle-analyzer/readme.md
2018-12-23 19:59:51 +01:00
Zihua Wu 24400d1e61 fix: update with-mobx example (#5936)
Babel related content in README.md is updated according to the updated .babelrc
2018-12-23 11:20:27 +01:00
Michael Hsu 62905ce683 Add with-carlo example (#5930)
This example show how you can use Next.js with [Carlo](https://github.com/GoogleChromeLabs/carlo).

```bash
npm run dev

npm run build
npm start
```

#### Demo

![large gif 582x438](https://user-images.githubusercontent.com/1527371/50331830-0ebd3100-053b-11e9-8d9c-d792ce0065fa.gif)
2018-12-21 09:56:36 +01:00
Tim Neutkens 9c4eefcdbf
Add prettier for examples directory (#5909)
* Add prettier for examples directory

* Fix files

* Fix linting

* Add prettier script in case it has to be ran again
2018-12-17 17:34:32 +01:00
Pojen Chen dfa0f82669 Remove <link ...style.css"> from Head in _document (#5890) 2018-12-15 02:57:33 +01:00
Juan Olvera 798ae043ac Example with cookie auth (#5821)
Fixes #153

This is my attempt at https://github.com/zeit/next.js/issues/153

Following @rauchg instructions:

- it uses an authentication helper across pages which returns a token if there's one
- it has session synchronization across tabs
- <strike>I deployed a passwordless backend on `now.sh` (https://with-cookie-api.now.sh, [src](https://github.com/j0lv3r4/next.js-with-cookies-api))</strike> The backend is included in the repository and you can deploy everything together by running `now`

Also, from reviewing other PRs, I made sure to:

- use [isomorphic-unfetch](https://www.npmjs.com/package/isomorphic-unfetch).
- use [next-cookies](https://www.npmjs.com/package/next-cookies).

Here's a little demo:

![GIF](https://i.imgur.com/067Ph56.gif)
2018-12-14 23:05:54 +01:00
Pojen Chen b4e877c8a8 Remove <link ...style.css"> from Head in _document (#5887) 2018-12-14 15:37:53 +01:00
Leon c2a208d141 Update styletron example (#5879)
Missed a fix for the styletron api. Previous config won't work for server rendering.
2018-12-13 17:23:06 +01:00
adrianoted 81a2a6c429 Removing link ref style.css (#5871)
This link ref is no more necessary to include in the Head Section.  It cause error 404 in the console: http://localhost:3000/_next/static/style.css net::ERR_ABORTED 404 (Not Found)
2018-12-13 00:30:43 +01:00
Oscar Busk 71d1d363ad Fix/update "examples/custom-server-typescript" (#5865)
* Update all dependencies and remove redundant ones from package.json. (60f9ee5)
* Fixes #5596 by adjusting nodemon scripts (d4b7d3a)
* Fixes `npm start` on windows by using `cross-env` (9555217)
* Move compiled server out from `.next`. Compiling other JS into `.next` seems incorrect. (79fce02, 
9ce7086)
* Partly fixes #5753 by making sure typescript compiles with `es2017` as target, at least ensuring code is runnable on node 8. Previously it was compiled with `esnext`. (9176e92)

--- 

I tried improving the structure by keeping source in `src/app` and `src/server` and then building to `dist/server` and `dist/app` but I didn't really get it to work and made most configs more complicated. Moved the built server out from `.next` anyway.
2018-12-12 11:04:39 +01:00
Brian Beck 50662c6a83 Fix initialNow in react-intl example (#5867)
The `initialNow` prop is used to avoid content mismatches when Universal/SSR apps render date values using components like `<FormattedRelative>`.

If this value is created in `render()`, then the server will generate it and then the client will also generate it during hydration / initial render, resulting in two different values and content mismatches like:

> Warning: Text content did not match. Server: "in 1,741,545 seconds" Client: "in 1,741,543 seconds"

If the value is instead generated in `getInitialProps`, then the client's initial rendering will match because it will use the same value sent down by the server.
2018-12-12 11:02:36 +01:00
Oscar Busk 4345343d88 Update/fix "examples/with-firebase-hosting-and-typescript" (#5864)
There were several issues with the example [examples/with-firebase-hosting-and-typescript](https://github.com/zeit/next.js/tree/canary/examples/with-firebase-hosting-and-typescript)
* `npm run serve`
  * Has no `pre` task that actually builds the app. Requires manual running of all build scripts.
  * Will choke on windows because trying to set environment variables with `NODE_ENV=production`
* Outdated Typescript and Tslint
* Not being able to deploy because `firebase-tools` being of a deprecated version.
* Structure, which I understand is based on `firebase-tools` generation, is confising with `src/functions/src` being generally bad structuring.

I remedied this and also improved some other factors:

* Remove dependency `prettier` as it is unused (f4d6f54)
* Upgrade all dependencies (09a9193)
  * Use upgraded firebase dependencies to deploy to node 8 environment (87e1e09, 7d8055b)
  * Remove deprecated tslint rule `no-unused-variable` (9392162)
* Flattened filestructure in `src/functions` (097a25a)
* Use ES import when importing next (6c99adb)
* Fixed incorrect name and added somewhat to the description in package.json.
  `with-firebase-hosting` → `with-firebase-hosting-and-typescript` (1ffa0b5)
* Fixed `serve` script by building before running, using [`cross-env`](https://www.npmjs.com/package/cross-env) to set environment variables and remove unecessary flag. (3a1e221, 422ccee, 8811e44)
* Add `.firebase` cache to `.gitignore` (4d7cbe4)
* Add `-C` (clean) flag when copying dependency files `copy-deps` (0826708)
* Use `strict: true` in the functions tsconfig (229b04f)

This was tested by running serve on windows and linx(WSL) and deploy on linux(WSL)

---

This is based on #5819 but correctly based from `canary`
2018-12-11 23:24:18 +01:00
Oscar Busk 82c5cc38d5 Update/fix "examples/with-firebase-hosting" (#5853)
Hello! 
I was looking at the [`with-firebase-hosting`](/zeit/next.js/tree/canary/examples/with-firebase-hosting) example and was having some various issues running it:

* `npm run serve` will choke on windows because trying to set enviroment variables with `NODE_ENV=production`
* `npm run build-funcs` failing because of babeljs mismatches between `@babel/cli@^7.0.0-rc.1` and `next@^6.0.3`
* Not being able to deploy because `firebase-tools` being a deprecated version.

I remedied this and also improved some other factors:

* Use standard JSON formatting on `package.json` so that `npm install` doesn't cause changes on every run. (a83e930)
* Remove "prettier" as a devDependency as there is no use of it in the example and most other examples does not have it as a dependency. (6095663)
* Update all dependencies. The simple usecase in this example didn't really require any changes to the code. (ccde086)
  * [`firebase-admin@6`](https://github.com/firebase/firebase-admin-node/releases/tag/v6.0.0)
  * [`firebase-functions@2`](https://github.com/firebase/firebase-functions/releases/tag/v2.0.0) 
  * [`firebase-tools@4`](https://github.com/firebase/firebase-tools/releases/tag/v4.0.0)
  * [`firebase-tools@5`](https://github.com/firebase/firebase-tools/releases/tag/v5.0.0)
  * [`firebase-tools@6`](https://github.com/firebase/firebase-tools/releases/tag/v6.0.0)
* Make `npm run serve` runnable on windows using [`cross-env`](https://www.npmjs.com/package/cross-env). (b20dda7)
* Update `.gitignore` to ignore firebase cache (bf761b7)
* Remove `src/app/.babelrc` that seems to have been added as a previous bugfix but doesn't seem to do anything currently. (1b02045)
* Remove point from [`README.md`](https://github.com/zeit/next.js/blob/canary/examples/with-firebase-hosting/README.md) that was mentioning any `predeploy` hooks in `firebase.json` as they were removed in 4f4b7a1bce. (5636d9f)
* Use the possibility added by upgrading `firebase-tools` to [`>=4.0.0`](https://github.com/firebase/firebase-tools/releases/tag/v4.0.0) and `firebase-functions` to [`>=2.0.0`](https://github.com/firebase/firebase-functions/releases/tag/v2.0.0) to make the deployable functions use node 8 rather than node 6. Also make babel compile with node 8 as target for less polyfills etc. (c954cc2)
  * Added comment to [`README.md`](https://github.com/zeit/next.js/blob/canary/examples/with-firebase-hosting/README.md) explaining how firebase deploys to node 8 and that babel will compile code for node 8. (d8b2e65, 91953dc)

This was tested to `serve` on windows, linux(WSL) and on mac. Deploy was tested on linux(WSL) and mac.

---

This PR is a based on #5806 with correct base.

---

🔔 @jthegedus @timneutkens
2018-12-11 11:45:58 +01:00
Tim Neutkens 6b7864e57e Fix linting 2018-12-10 22:05:53 +01:00
Diogo Dutra a996fba09c Added a new example with relay modern and a graphql server with express. (#4670)
* Added a new example with relay modern and a graphql server with express.

* removed .graphqlconfig file from with-relay-modern-server-express example
2018-12-10 16:50:35 +01:00