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

662 commits

Author SHA1 Message Date
Jan Mühlemann e11d08ae45 Update with react 18next to latest (#5017)
* update with-react-i18next supporting new _app.js

* update readme to not encourage cloning of repo
2018-08-24 09:49:10 +02:00
dengyun b32763b9e3 fix: SyntaxError @import "./themes/default" (#5018)
fix: bug 🐞

![image](https://user-images.githubusercontent.com/37728280/44520939-05929380-a704-11e8-9e7e-7acbc08c6d39.png)
2018-08-23 16:48:17 +02:00
HaNdTriX 5ff7c0742c Lint examples (#4985)
* Lint examples/with-apollo-and-redux-saga

* Lint examples/with-apollo-auth

* Lint examples/with-apollo

* Lint exampels/with-google-analytics

* Lint examples/with-higher-order-component

* Lint examples/with-react-i18next

* Lint exampels/with-redux

* Lint exampels/with-relay-modern

* Lint examples/with-universal-configuration-runtime

* Add **/examples/**/lib/** to linter
2018-08-20 08:31:24 +02:00
rouzbeh84 639df91c87 docs: removes npx info & moves src link up (#4972)
FIXES: #4970 

confirmed rest of instructions work so left them in, even though duplicate of guide over at Material UI. thoughts?
2018-08-19 22:26:50 +02:00
HaNdTriX edaf1b42a6 Fix with-jest example (#4978)
Running the [with-jest](https://github.com/zeit/next.js/tree/canary/examples/with-jest) example  results in the following error:

```log
 FAIL  __tests__/index.test.js
  ● Test suite failed to run

    SecurityError: localStorage is not available for opaque origins
      
      at Window.get localStorage [as localStorage] (node_modules/jsdom/lib/jsdom/browser/Window.js:257:15)
          at Array.forEach (<anonymous>)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.943s
Ran all test suites.
error Command failed with exit code 1.
```

Upgrading the dependencies (jest) to the latest version helps!

[More info](https://github.com/jsdom/jsdom/issues/2304)

Related #4776
2018-08-17 11:20:56 -07:00
ǝlzlǝoq lǝᴉuɐp ツ 87f5df2454 Factor out NextScript inline source (#4934) (#4939)
This PR factors out the inline script into an own static method; fixes #4934.
2018-08-14 11:05:25 -07:00
Jacob Page 1889c80472 Update routing samples (#4864)
Updated router samples to use the EventEmitter
2018-08-13 14:17:39 -07:00
Luc b9081a5115 Replace deprecated props.url in examples (#4953)
Following https://github.com/zeit/next.js/pull/4952

I found two examples with the deprecated`props.url` :
- `with-ioc`
- `with-next-routes`
2018-08-13 14:12:03 -07:00
Luc b516d094a4 Fix shallow routing examples using old React lifecycle and deprecated props.url (#4950)
* replace componentWillReceiveProps by componentDidUpdate

* replace props.url by withRouter HOC

* fix deprecated `props.url` in with-shallow-routing example
2018-08-13 11:09:45 -07:00
Alexander Kachkaev 9319c158a5 Upgrade Babel to 7.0.0-rc.1 (major) (#4937)
Fixes #4691
Fixes #4614

This PR gives path to https://github.com/zeit/next-plugins/pull/242

I did not add or remove `^` near dependency versions in package.json files. However, I don't exclude that some changes can be made given that rc is more stable than beta.
2018-08-13 10:34:08 -07:00
Tomek e8c1eaec83 update with-loading example (#4836)
Changes:

* Split `Header` component trough `_document.js` and `_app.js`
* Attached Router events with a way described in the [documentation](https://github.com/zeit/next.js#router-events) (though in the documentation is says it should be `Router.events.on` while I managed to get it working only by `Router.router.events.on` and I had to place it inside `componentDidMount`)
2018-08-11 19:39:48 -07:00
Tim Phillips b990b29d2d Update Apollo links in examples (#4933) 2018-08-09 14:00:08 -07:00
Sahal Sajjad 136585e296 Added example: with-typestyle (#4926)
* Added example: with-typestyle

* Fixed bug: Rendering the DOM tree twice
2018-08-08 21:36:34 -07:00
HaNdTriX 06b02e2c62 Update with-custom-babel-config example (#4923)
## Issue

Running [examples/with-custom-babel-config](https://github.com/zeit/next.js/tree/canary/examples/with-custom-babel-config) will result in the following error message:

```
./pages/index.js
Module build failed (from /some_path/next.js/dist/build/webpack/loaders/next-babel-loader.js):
Error: [BABEL] /some_path/next.js/examples/with-custom-babel-config/pages/index.js: 
As of v7.0.0-beta.55, we've removed Babel's Stage presets.
Please consider reading our blog post on this decision at
https://babeljs.io/blog/2018/07/27/removing-babels-stage-presets
for more details. TL;DR is that it's more beneficial in the
  long run to explicitly add which proposals to use.

...
```

## Explanation

Babel removed Babel's Stage presets on July 27, 2018.

More info: https://babeljs.io/blog/2018/07/27/removing-babels-stage-presets

## Solution

I've updated the example so ist just uses the babel plugin it actually needs.

## Related 

Closes: #4772
2018-08-08 09:02:46 -07:00
HaNdTriX d3f1fa630e Rewrite with-dotenv example (#4924)
## Issue

I decided to rewrite the [with-dotenv](https://github.com/zeit/next.js/tree/canary/examples/with-dotenv) using [dotenv-webpack](https://github.com/mrsteele/dotenv-webpack) example because:

- changes doesn't get applied  (#4748, brysgo/babel-plugin-inline-dotenv#13)
- the production mode doesn't work at all
- this approach has already been used in the [examples/relay-modern](9320d9f006/examples/with-relay-modern/next.config.js)
- it is [documented](https://webpack.js.org/plugins/environment-plugin/#dotenvplugin) by webpack

## Alternatives

* remove/deprecate example
* fix babel-plugin-inline-dotenv

## Related

Closes: #4748
2018-08-08 09:01:00 -07:00
HaNdTriX 9018da11ca Remove with-global-stylesheet example (#4913)
* Deprecate with-global-stylesheet example

Use @zeit/next-css instead

https://github.com/zeit/next-plugins/tree/master/packages/next-css

RELATED ISSUE: #4902

* Deprecate with-global-stylesheet-simple example

Use @zeit/next-css instead

https://github.com/zeit/next-plugins/tree/master/packages/next-css

RELATED ISSUE: #4902
2018-08-07 18:36:28 -07:00
HaNdTriX 3286ecb3fc Add slate.js example (#4899) 2018-08-06 21:00:31 -07:00
Thomas Hermann 83970c908d Add with-strict-csp example (#4858) 2018-08-06 20:19:16 -07:00
Hugo Heyman e8aa78204a Improve glamor example (#4893)
Changes:
- Use css prop on the element to style it
- Add webpack + babelrc configuration to remove otherwise needed import boilerplate [according to glamor docs](https://github.com/threepointone/glamor/blob/master/docs/createElement.md)

Rationale: The killer feature of glamor that makes it so great is that it relieves you from naming classes/styles if you use the custom css prop. Together with the babel plugin you also don't need any extra import wherever the css prop is used.

All the real world uses I've seen of glamor has used the css props so I think the example should reflect this. As an example here is docs how to use glamor with gatsby (using the css prop):
https://www.gatsbyjs.org/docs/glamor/
2018-08-05 16:13:28 -07:00
Kate 05b6891620 Fixed server status message in with-redux-observable-example. (#4900)
**Changes:**
- Fixed "was character fetched on server" message by properly passing `isServer`.
- Stop fetching if there was an error (currently it keeps sending requests to the same endpoint every 3 sec)

**Related:**
- https://github.com/zeit/next.js/pull/4818
- https://github.com/zeit/next.js/issues/4724
2018-08-05 10:56:04 -07:00
Tomek b1459bfd60 update with-sentry example (#4859)
Changes:

* moved the configuration from HOC to `_app.js`
* fixed the example, as `componentDidCatch` catches errors during rendering phase, but not within event handlers.
2018-08-04 10:51:35 -07:00
Max Stoiber 80202069cf Note babel-plugin-styled-components (#4882)
Otherwise folks might miss that part and get checksum mismatches!
2018-08-01 13:57:30 +02:00
José Manuel Aguirre 7282f43f7b Missing babel configuration in sw-precache example (#4856)
Missing configuration in package.json and .babelrc causes this example to be broken after installing and running the example.
2018-07-27 22:54:01 +02:00
Tomek 88610694c2 update with-prefetching example (#4850) 2018-07-27 22:08:09 +02:00
Tim Neutkens 283e9afe70
Upgrade serve (#4857) 2018-07-27 21:13:55 +02:00
Tomek f4988e7fa3 update with-markdown example (#4839)
Changes:

* replaced the `markdown-in-js` with nextjs plugin for `MDX`

Highly inspired by the example from [MDX repository](https://github.com/mdx-js/mdx/tree/master/examples/next)
2018-07-25 20:06:40 +02:00
Tomek c090a57e77 update with-flow example (#4835)
Changes:
* updated packages
* moved the content of `layout` to `_app.js` and created simple `Page` component
* replaced `import * as React` because it is not necessary to import everything
* moved `next.js.flow` to `flow-typed` as it is default directory for library definitions
* updated the gif
2018-07-25 13:42:40 +02:00
Tomek d1fbcfe5de update with-asset-import example (#4830)
Changes:
- use `next-images` plugin for handling static files import
2018-07-24 19:11:21 +02:00
Rustam Gilyaziev e2b518525c Update with-react-intl example (#4825)
Changes:
- added withIntl HOC because injectIntl do no hoist static methods
- fixed `Cannot read property 'locale' of undefined`
2018-07-24 00:43:57 +02:00
Tomek b1222962f0 update client-only-render-external-dependency example (#4822)
Changes:
* use `dynamic` imports instead of `require`
* update `recharts` dependency
2018-07-22 20:53:22 +02:00
Tomek 53853d3fa9 update with-redux-observable example (#4818) 2018-07-22 01:37:59 +02:00
Tomek 822cc3c863 update with-react-intl example (#4817) 2018-07-22 01:37:25 +02:00
Tomek 0d93d42640 update with-react-ga example (#4816)
Changes:
* updated `react-ga` package
* updated README.md
* Removed `Layout` component and used custom App component
* used `routeChangeComplete` to log route changes.
2018-07-21 19:27:48 +02:00
Adrian Li 6ef7625ba6 Update example: Semantic-UI (#4815)
The existing example currently does not work because of outdated usage patterns. This PR seeks to update these patterns to the latest recommended best practice while bumping versions.

# Summary

- Bumped version numbers in `package.json`;
- Moved `<link />` tag from `pages/index.js` to `pages/_document.js` as is [recommended](https://github.com/zeit/next-plugins/tree/master/packages/next-css#usage);
- Replace individual css/font imports with import of minified CSS as is [recommended](https://react.semantic-ui.com/usage#semantic-ui-css-package);
- Removed prop (no longer used) from `<List />` element.
2018-07-21 12:42:38 +02:00
Brian Kim 0298c722b1 improve custom-server-fastify example (#4805)
I’ve been experimenting with Next.js and Fastify and I made the following changes to the Fastify example based on what I found:

### Use Fastify’s plugin API
IMO putting Fastify’s listen call in a promise callback is an anti-pattern, b/c the Fastify plugin API is meant to solve the problem of async server bootstrapping.

[From Fastify’s Getting Started docs](https://www.fastify.io/docs/latest/Getting-Started/):
> Fastify provides a foundation that assists with the asynchronous bootstrapping of your application.

### Set reply.sent in handlers which return promises

[From Fastify’s Routes docs](https://www.fastify.io/docs/latest/Routes/#promise-resolution):
> If your handler is an `async` function or returns a promise, you should be aware of a special behaviour which is necessary to support the callback and promise control-flow. If the handler's promise is resolved with `undefined`, it will be ignored causing the request to hang and an *error* log to be emitted.
>
> 1. If you want to use `async/await` or promises but respond a value with `reply.send`:
>     - **Don't** `return` any value.
>     - **Don't** forget to call `reply.send`.
> 2. If you want to use `async/await` or promises:
>     - **Don't** use `reply.send`.
>     - **Don't** return `undefined`.

`app.render` returns a promise which contains undefined, so returning it in a Fastify handler will log an error. However, returning anything besides undefined will cause Fastify to try to write to the response which Next.js has already ended. The solution is to manually set the `reply.sent` flag to true when any Next.js rendering promise is fulfilled as an alternative to calling `reply.send`.

### Make Next.js handle 404 errors
This allows any route to throw a NotFound error and let Next.js handle the rendering of the 404 page.

### Make Next.js handle any route which starts with `_next` in dev
This prevents dev routes from being caught by user-defined routes.
2018-07-19 21:27:22 +02:00
Tim Neutkens 6415d5f4ee
Upgrade fastify in custom-server-fastify (#4801) 2018-07-19 00:18:15 +02:00
Tim Neutkens 76657f8451
Upgrade serve in with-static-export example (#4800) 2018-07-18 22:16:06 +02:00
David Calhoun 6f4925c193 [change] Update RNW example (#4787) 2018-07-15 20:59:20 +02:00
Kenneth Luján Rosas dca2ca6f2b [with-apollo] simplify apolloState prop (#4755)
As seen on `with-apollo-auth` there are some things that need to be addressed here too.

* #4554 remove useless `apolloState` from App props on `getDataFromTree`
* #4563 simplify `apolloState` prop

Let me know if further changes/fixes are needed. 
Thank you 🎉
2018-07-12 18:59:28 +02:00
Michael Herold 5b3578e58f #4751 - Explicitly mention install when cloning examples (#4758)
Preferably this installation wouldn't be necessary, but in lieu of a fix...

#4751
2018-07-11 23:56:15 +02:00
jhartley218 ad2d4432e7 Update @types/next to latest in typescript example. (#4750)
Updating to a more recent version of `@types/next` fixes an error I encountered while building a new app on top of the "with-typescript" example:

`Property `push` not found in SingletonRouter`

Additional context: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/26665

To test, add a simple Router.push operation to the `pages/index.tsx`

```
import Router from 'next/router'
// ...
<span onClick={() => Router.push({ pathname: '/about' })}>TEST</span>
```
2018-07-09 13:32:52 +02:00
Brendan Houle d7d61d3d4a Prepend polyfills only once (#4643) (#4738) 2018-07-06 11:54:16 +02:00
NikitaVlaznev 728871b005 Apollo example: avoid double render in browser (#4734)
Apollo's getDataFromTree is supposed to be called during the server side rendering.
Being called in browser it fires an unnecessary fake render process and blocks components from rendering with loading=true.

Also there was a mistake in this code:

    // `getDataFromTree` renders the component first, the client is passed off as a property.
    // After that rendering is done using Next's normal rendering pipeline
    this.apolloClient = props.apolloClient || initApollo(props.apolloState.data)

**Apollo** component is not rendered by getDataFromTree actually, it renders the **App** directly, thus props.apolloClient will always be undefined.

This example was discussed here: https://github.com/zeit/next.js/issues/387.
2018-07-05 20:49:23 +02:00
Michael Hsu a1f5f35c2e fix(with-pkg): Rename dist to server (#4727)
This PR is a follow-up to 6.1 breaking #4506: Rename `dist` to `server`
2018-07-04 15:12:36 +02:00
Junyoung Choi (Sai) a25359bf3f Improve with-mobx example (#4705)
in flavor of https://github.com/zeit/next.js/pull/4377
2018-06-30 22:29:24 +02:00
Vinicius Pacheco Furtado de6bf4e75f Fix typescript examples (#4704)
Update @zeit/next-typescript version on examples using it
2018-06-30 22:23:38 +02:00
Gary Meehan 0da53a1444 Add [with-storybook] example (#4588)
The purpose of the PR is to add the simplest possible integration with Storybook. 

It leaves the default Storybook and also adds a custom component to show how it would be used in both the app and Storybook.

Update: 
Tested with latest 👉  6.1.1
2018-06-29 22:24:44 +02:00
Gary Meehan 6a489efc1a [hello-world example] remove unused file (patch)
Removes unused file
Adds note on `day` subdirectory.
2018-06-29 22:23:39 +02:00
dengyunxie 4744fbd096 Make the file beautiful (#4694)
unified format😀😋
2018-06-29 17:02:00 +02:00
Niklas Wagner dde20fc841 Added note for AWSAppSyncClient (#4611)
I had some trouble to get server side rendering with the AWSAppSyncClient working. I finally found a solution in https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/82 but it might be worth to share it here as well. Instead of adding a big code block to each file I'll just refer to this Pull Request.

______

In case you want to use the `AWSAppSyncClient` you just need to replace the `create()` function with this function:
```jsx
import AWSAppSyncClient from 'aws-appsync';
import { AUTH_TYPE } from 'aws-appsync/lib/link/auth-link';

function create(initialState) {
  const client = new AWSAppSyncClient({
    url: AWS_AppSync.graphqlEndpoint,
    region: AWS_AppSync.region,
    auth: {
      type: AUTH_TYPE.API_KEY,
      apiKey: AWS_AppSync.apiKey,

      // Amazon Cognito Federated Identities using AWS Amplify
      //credentials: () => Auth.currentCredentials(),

      // Amazon Cognito user pools using AWS Amplify
      // type: AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
      // jwtToken: async () => (await Auth.currentSession()).getIdToken().getJwtToken(),
    },
    disableOffline: true,
  }, {
    cache: new InMemoryCache().restore(initialState || {}),
    ssrMode: true
  });

  return client;
}
```
2018-06-29 10:08:26 +02:00