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

715 commits

Author SHA1 Message Date
Supakorn Thongtra fef6026ad9 <title> should not be used in _document.js's (#5379)
* <title> should not be used in _document.js's

* fix style as it was
2018-10-05 23:53:52 +02:00
Carlos 334b46e8d9 Add analyze bundles example (#5332)
* Add analyze-bundles example

* housekeeping: with-webpack-bundle-analyzer example

* analyze-bundles example: revert the version of faker library

* analyze-bundles add analyze:server and analyze:browser to scripts

* with-webpack-bundle-analyzer example: fix typo
2018-10-01 01:24:27 +02:00
Carlos 565b026e7b Added with-ts-node with Next js 7 example (#5204)
### Next js 7+ and Typescript 3+ Example

No babel, tsc, pure typescript usage
Made by [next-with-typescript plugin](https://github.com/echoulen/next-with-typescript)
2018-09-28 21:18:50 +02:00
Mert Can 2c6206d66c Package.json comma removed (#5322) 2018-09-28 15:37:19 +02:00
Yuri Yakovlev ad93ff4b3e Remove transform-decorators plugin & Bump deps (#5232) 2018-09-27 23:42:06 +02:00
Henrik Wenz f0f8229009 Update with-mobx-state-tree-typescript example (#5266)
To work with babel7 & next7.
2018-09-27 16:39:11 +02:00
Arek Mytych 5c9c7b877b Add language switch to with-react-i18next example (#5306) 2018-09-27 13:49:33 +02:00
Resi Respati 397daece42 with-typescript example updates (#5267)
* [with-typescript] Updated `@zeit/next-typescript` and typescript typings

* [with-typescript] Updated tsconfig to match new recommended config

* [with-typescript] upgraded dependencies, implement type-checking

* [with-typescript] add _document example, fixed tsconfig

* [with-typescript] updated README

* [with-typescript] updated example contents

* [with-typescript] adopt the Layout component from Flow example
2018-09-26 09:58:36 +02:00
Matthew Francis Brunetti 7961946c07 withApollo example - move from old HOC APIs to new function-as-child APIs (#5241)
Since version 2.1, react-apollo is exposing some new components that use the function-as-child (or render-prop) pattern to let you connect apollo-client magic with your components. See the blog article: [New in React Apollo 2.1](https://www.apollographql.com/docs/react/react-apollo-migration.html)

If I'm not mistaken, it's generally agreed that this pattern is (where it works) superior to the HOC pattern, for reasons that are best explained here: https://cdb.reacttraining.com/use-a-render-prop-50de598f11ce 

So I updated the with-apollo example to use the new API, and IMO this code is much simpler and natural to read and understand, especially if you are not already familiar with Apollo's HOC APIs.

I broke up my changes into separate commits, for easier review. Commits with "Refactor" in the message accomplish the goal of switching to the new APIs while minimizing line-by-line differences (select "Hide whitespace changes" under "Diff settings"). Commits with "Clean up" in the message follow up the refactoring with trivial things like reorganizing code sections, renaming variables, etc.

For the components doing mutations, I chose not to use the `Mutation` component, since that doesn't really make sense to me; a mutation is something that happens at a point in time, so it's not meaningful to represent a mutation in the markup, which exists for a period of time. All that component does is expose a `mutate` function for a single specified mutation, and `result` data for a single firing of the mutation (which we don't need anyways; apollo handles updating the local data with the result). To me it seems simpler and more flexible to just get the apollo client via `ApolloConsumer` and call `.mutate()` on it. 

In case anyone is interested, here's what my version of `PostUpvoter` using the `Mutation` component looked like:

 <details>

```jsx
import React from 'react'
import { Mutation } from 'react-apollo'
import { gql } from 'apollo-boost'

export default function PostUpvoter ({ votes, id }) {
  return (
    <Mutation mutation={upvotePost}>
      {mutate => (
        <button onClick={() => upvote(id, votes + 1, mutate)}>
          {votes}
          <style jsx>{`
            button {
              background-color: transparent;
              border: 1px solid #e4e4e4;
              color: #000;
            }
            button:active {
              background-color: transparent;
            }
            button:before {
              align-self: center;
              border-color: transparent transparent #000000 transparent;
              border-style: solid;
              border-width: 0 4px 6px 4px;
              content: '';
              height: 0;
              margin-right: 5px;
              width: 0;
            }
          `}</style>
        </button>
      )}
    </Mutation>
  )
}

const upvotePost = gql`
  mutation updatePost($id: ID!, $votes: Int) {
    updatePost(id: $id, votes: $votes) {
      id
      __typename
      votes
    }
  }
`
function upvote (id, votes, mutate) {
  mutate({
    variables: { id, votes },
    optimisticResponse: {
      __typename: 'Mutation',
      updatePost: {
        __typename: 'Post',
        id,
        votes
      }
    }
  })
}
```

</details>

###

I'm happy with where things are at here, but I'm more than happy to address any comments, concerns, ideas for improvent!

Thanks!
2018-09-26 01:32:41 +02:00
Zack Tanner 9854c342e1 #5620: Fix react-i18next example to properly SSR (#5265)
This fixes https://github.com/zeit/next.js/issues/5260 by making sure that `index.js` has `getInitialProps` defined on the page exported component, not the child component.

When fixing that, I uncovered an issue where the server side rendered HTML did not match the clientside HTML, so I reworked _app.js to use the `i18nextprovider` component which has props to hydrate the initial data (for SSR), and makes sure the correct i18n instance is passed to all child components through context.

Before:
```html
<!DOCTYPE html>
<html>
   <head>
      <meta charSet="utf-8" class="next-head"/>
      <link rel="preload" href="/_next/static/development/pages/index.js" as="script"/>
      <link rel="preload" href="/_next/static/development/pages/_app.js" as="script"/>
      <link rel="preload" href="/_next/static/development/pages/_error.js" as="script"/>
      <link rel="preload" href="/_next/static/runtime/webpack.js" as="script"/>
      <link rel="preload" href="/_next/static/runtime/main.js" as="script"/>
   </head>
   <body>
      <div id="__next"></div>
      <script src="/_next/static/development/dll/dll_4a2ab6ce0cb456fbfead.js"></script><script>__NEXT_DATA__ = {"props":{"pageProps":{}},"page":"/","pathname":"/","query":{},"buildId":"development"};__NEXT_LOADED_PAGES__=[];__NEXT_REGISTER_PAGE=function(r,f){__NEXT_LOADED_PAGES__.push([r, f])}</script><script async="" id="__NEXT_PAGE__/" src="/_next/static/development/pages/index.js"></script><script async="" id="__NEXT_PAGE__/_app" src="/_next/static/development/pages/_app.js"></script><script async="" id="__NEXT_PAGE__/_error" src="/_next/static/development/pages/_error.js"></script><script src="/_next/static/runtime/webpack.js" async=""></script><script src="/_next/static/runtime/main.js" async=""></script>
   </body>
</html>
```

After: 
```html
<!DOCTYPE html>
<html>
   <head>
      <meta charSet="utf-8" class="next-head"/>
      <link rel="preload" href="/_next/static/development/pages/index.js" as="script"/>
      <link rel="preload" href="/_next/static/development/pages/_app.js" as="script"/>
      <link rel="preload" href="/_next/static/development/pages/_error.js" as="script"/>
      <link rel="preload" href="/_next/static/runtime/webpack.js" as="script"/>
      <link rel="preload" href="/_next/static/runtime/main.js" as="script"/>
   </head>
   <body>
      <div id="__next">
         <h1>This example integrates react-i18next for simple internationalization.</h1>
         <div>
            <h1>welcome to next.js</h1>
            <p>This example integrates react-i18next for simple internationalization.</p>
            <p>test words for en</p>
            <div><button>fire in the wind for en</button></div>
            <p>You can either pass t function to child components.</p>
            <p>Or wrap your component using the translate hoc provided by react-i18next.</p>
            <p>Alternatively, you can use <code>Trans</code> component.</p>
            <a href="/page2">Go to page 2</a><br/><a href="/page3">Go to page 3 (no hoc)</a>
         </div>
      </div>
      <script src="/_next/static/development/dll/dll_4a2ab6ce0cb456fbfead.js"></script><script>__NEXT_DATA__ = {"props":{"pageProps":{"i18n":null,"initialI18nStore":{"en":{"home":{"welcome":"welcome to next.js","sample_test":"test words for en","sample_button":"fire in the wind for en","link":{"gotoPage2":"Go to page 2","gotoPage3":"Go to page 3 (no hoc)"}},"common":{"integrates_react-i18next":"This example integrates react-i18next for simple internationalization.","pureComponent":"You can either pass t function to child components.","extendedComponent":"Or wrap your component using the translate hoc provided by react-i18next.","transComponent":"Alternatively, you can use \u003c1\u003eTrans\u003c/1\u003e component."}}},"initialLanguage":"en-US"}},"page":"/","pathname":"/","query":{},"buildId":"development"};__NEXT_LOADED_PAGES__=[];__NEXT_REGISTER_PAGE=function(r,f){__NEXT_LOADED_PAGES__.push([r, f])}</script><script async="" id="__NEXT_PAGE__/" src="/_next/static/development/pages/index.js"></script><script async="" id="__NEXT_PAGE__/_app" src="/_next/static/development/pages/_app.js"></script><script async="" id="__NEXT_PAGE__/_error" src="/_next/static/development/pages/_error.js"></script><script src="/_next/static/runtime/webpack.js" async=""></script><script src="/_next/static/runtime/main.js" async=""></script>
   </body>
</html>
```
2018-09-24 12:13:38 +02:00
John Leon ce8b301f24 Fix for with-ant-design-less for next7.0 (#5263)
* Update .babelrc

babel-plugin-transform-decorators-legacy does not exist in babel 7 in replace use @babel/plugin-proposal-decorators

* Update package.json

Acording the last commit please,  test this example , will be work .
2018-09-24 00:03:38 +02:00
Adam Lane 3bb62928a6 example with-sentry note that server side logging available too (#5261)
Trivial note to remind anyone doing sentry that they should consider doing server side logging too.
2018-09-23 21:06:05 +02:00
Adam Lane 48d54c254f example with-apollo note that two render executions are expected (#5262)
Noting per https://github.com/zeit/next.js/issues/5050 for new users of Apollo that they should not be concerned about multiple renders.
2018-09-23 21:05:00 +02:00
Henrik Wenz 80a6160caf Update with-dynamic-import example (#5201)
Follow up on: https://github.com/zeit/next.js/pull/4639
2018-09-23 16:01:54 +02:00
Henrik Wenz 60b1d26f1f Update with-kea example (#5259)
- updates transform-decorators-legacy
- updates with-next-redux-wrapper
2018-09-23 16:01:37 +02:00
Henrik Wenz dc3be63ad2 Fix with-mobx-state-tree example (#5258) 2018-09-22 22:21:54 +02:00
Henrik Wenz 2c0ff4b925 Fix failing linter tests (#5257)
Wonder how that one got through 🤔
2018-09-22 21:41:07 +02:00
Arek Mytych 5276734535 Update to use @sentry/browser, remove raven-js (#5253) 2018-09-22 14:22:24 +02:00
Muhaimin CS e892898dfe Update with-redux-code-splitting example (patch) (#5252) 2018-09-22 14:14:40 +02:00
Arek Mytych 2304300d68 Update GrpahQL dependencies (#5242)
Fixes the example with next.js@7

Fixes #5238
2018-09-21 11:49:24 +02:00
Alessandro a39ce550e4 FIX #5234 (#5235)
FIX https://github.com/zeit/next.js/issues/5234

It simply needed to update dependencies
2018-09-20 21:09:29 +02:00
Tim Neutkens 8d649d1b4b Upgrade next plugins to the latest version in examples 2018-09-20 16:04:32 +02:00
Eugene 648e07f187 Update with-mobx example (#5229)
Update to new @babel/plugin-proposal-decorators, @babel/plugin-proposal-class-properties plugins version.
2018-09-20 14:29:57 +02:00
Yuri Yakovlev 2d763e08a8 Remove useless link tag in the head of Ant design example (#5227) 2018-09-20 13:26:11 +02:00
Ian Mitchell 0e4d2a15a7 Fix Example Deploy Links (#5216) 2018-09-20 11:32:16 +02:00
Julien Bouquillon cfcff160de doc: fix deploy link (#5223) 2018-09-20 11:30:23 +02:00
Tim Neutkens a616656f19 Upgrade @zeit/next-sass
Fixes #5210
2018-09-20 00:43:57 +02:00
Tim Neutkens b6c8d2a4ac Merge branch 'canary'
# Conflicts:
#	package.json
2018-09-19 18:15:57 +02:00
Tim Neutkens ee3a73f80b Add WebAssembly example 2018-09-17 21:48:06 +02:00
Stephen Sauceda e2d331dbcc add mocha example (#5182)
Adding an example of testing with Mocha

#4767
2018-09-17 00:12:39 +02:00
maurodaprotis 1f64082c03 Add with-context-api example (#5154)
* Add with-context-api example

* Change next dependency to canary and fix CounterProvider import
2018-09-14 12:04:29 +02:00
Rafael Almeida 5d147a82c4 Update with-ant-design example (#5141)
There is no need to wrap every page with a component when you can use the custom document.
2018-09-12 17:24:37 +02:00
Marcelo Zapaia ae7e53239a FIX with-apollo-auth example token access (#4771)
in some cases access to the token doesn't work in client side. this access to the token once in getInitialProps method and pass it down using props
2018-09-12 17:19:32 +02:00
Henri b79bbecb13 Add react-jss example (#5140)
Added a clear example on how to use react-jss with injecting the styles on the server.

cssinjs/jss#457
2018-09-12 15:49:54 +02:00
Tim Neutkens 344d770a28
Upgrade with-jest dependencies (#5149) 2018-09-12 15:29:17 +02:00
Kyle Holmberg f85a0bd550 Update next.config in with-webpack-bundle-analyzer example to avoid issue with Next.js in CI (#5135)
See: https://spectrum.chat/thread/030243b0-7ebf-434c-8e02-5f54ea30f3b6

Build works now 💃
2018-09-10 12:00:45 +02:00
Keith Grennan 8f61c335cb [with-apollo-auth] Only run getDataFromTree() on server (fix #4775) (#5112)
Though it sounds like some folks do run getDataFromTree() on the client in order to avoid loading states, it's non-standard usage and potentially confusing.  Also it's inconsistent with the other with-apollo examples.
2018-09-06 09:45:16 +02:00
Giovanni Giordano 0fa642aacf Update with-hashed-statics example (#5100)
* Add file-loader to webpack config

* Fix lint problems
2018-09-05 15:16:05 +02:00
Tim Neutkens 7627eb87d6
Use publicRuntimeConfig for universal-configuration-runtime example (#5101) 2018-09-05 14:38:39 +02:00
Jacob Page 777aab2b42 Remove unused flow definitions (#5094)
The `with-flow` sample has some obsolete definitions which are unused by the sample code. Removing the un-imported declarations is the easiest approach.
2018-09-05 13:38:28 +02:00
Diogo Dutra 56937fd22c Fixed package.json (#4654)
Fix on relay script to proper ignore schema files
   added graphql as explict dependency
2018-09-04 17:50:44 +02:00
Emmanuel Letallieur 82bdd43285 Fix custom-server-typescript not typechecking (#3954)
Hi

In the current version of the example __custom-server-typescript__, types are never checked.
For instance, change the following line :
```
const dev = process.env.NODE_ENV !== 'production'
```
by :
```
const dev: number = process.env.NODE_ENV !== 'production'
```
then run `npm run dev`. The application launches perfectly, no error is thrown.

In dev environnement, it is preferable to check types all the time, to get immediate feedback. This PR activates type checking. Only when using nodemon, so no impact on production.


Now the above code will (rightfully) refuse to compile : 
```
TSError: ⨯ Unable to compile TypeScript
server/index.ts (6,7): Type 'boolean' is not assignable to type 'number'
```
2018-09-04 17:35:34 +02:00
Kelly Burke 64f3720e7f Update example: with-sitemap-and-robots-express-server (#4579)
I simplified the example by removing `.eslintrc.js` and related packages, as well as `nodemon`. 

I also added a description in the README to address the question by @kachkaev in the original pull request (#4163).
2018-09-04 17:18:05 +02:00
Don Alvarez d4a54b6122 Add with-mobx-state-tree-typescript example (re-submitting due to accidental deletion) (#5077)
I think I accidentally deleted the branch my prior PR was based on before you had a chance to merge or decide whether to merge. In case I borked things with that delete, I'm resubmitting the PR and figuring you can close one or the other or both as desired.

Original notes:

Based on with-mobx-state-tree, but typescript instead of javascript

Aside from a few bits of typing and renaming .js files to .ts and .tsx, most of the the edits are to avoid warnings and errors when running the code through tslint (which can be done via the `npm run tslint` command in the example if desired).

To keep this example simple, the `<styled>` component (which is used by the javascript-based with-redux and with-mobx-state-tree examples for the clock component) is not used in this example. The `<styled>` library can of course be used with typescript but (I think) it requires a more complicated set of typescript and babel .configs than is needed for most other components and libraries, so I'm just directly styling the one formerly `<styled>` div to keep things simple and broadly applicable.
2018-09-04 17:17:30 +02:00
A K b00a140d58 added example with IBM Carbon Components, with demonstrated customizability (#4932) 2018-09-04 17:16:54 +02:00
Tim Neutkens a6114d4d65
Fix dependencies (#5091) 2018-09-04 13:17:22 +02:00
Henrik Wenz c44dab63ff Add with-yarn-workspaces example (#5034)
> Workspaces are a new way to setup your package architecture that’s available by default starting from Yarn 1.0. It allows you to setup multiple packages in such a way that you only need to run yarn install once to install all of them in a single pass.

- [x] Tested in development mode
- [x] Tested in production mode
- [x] Tested with deployment https://with-yarn-workspaces-hwzubdlkul.now.sh/
- [x] Added transpile module example

Closes #3638
2018-09-03 23:41:45 +02:00
Don Alvarez 14c7b25fcc Add with-sitemap-and-robots-express-server-typescript example (#5076)
Pulling out a few core points from the readme...

This example builds from /src into /dist, managing the different expectations of express.js (es5, commonjs) and next.js (es6) by using a pair of tsconfig.json files, both of which are run by `npm run build-ts` or any of the other npm targets.

Hot module reloading is largely but not completely wired up (nodemon is watching /dist but tsc isn't set up to watch /src and transpile changes in /src to /dist automatically (that's mainly because I wasn't sure how to start both nodemon and a pair of tsc watchers and be confident all would get shut down when the user killed dev mode). The readme suggests running `npm run build-ts` manually in another window to push changes from /src into /dev and on into the browser. 

tslint is also wired up via `npm run tslint`
2018-09-03 16:43:19 +02:00
Adam Lane 3d9564215c example with-reasonml dependency updates (#5048)
The original example fails to compile on my windows machine but updating bs-platform fixes that.
Depending on bs-next causes example to fail (package compiled with old incompatible version of bs-platform) so I have included it in a bindings directory where it can serve as an example of reason bindings.
Sources have been migrated to the latest reason-react.
2018-09-03 01:38:54 +02:00
Ivan Starkov 954fcb9674 Fix react-intl example (#4840)
react-intl does not work otherwise
2018-09-02 23:53:43 +02:00