Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first readme example breaks #55

Closed
davemo opened this issue Oct 25, 2016 · 3 comments
Closed

first readme example breaks #55

davemo opened this issue Oct 25, 2016 · 3 comments

Comments

@davemo
Copy link

davemo commented Oct 25, 2016

screen shot 2016-10-25 at 1 20 17 pm

$ node -v
v7.0.0
$ npm -v
3.10.8
$ tree . -L 2
.
├── package.json
└── pages
    └── index.js
$ cat pages/index.js 
import React from 'react'
export default () => {
  <div>Welcome to next.js!</div>
}
$ cat package.json 
{
  "name": "next-play",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "dependencies": {
    "next": "^1.0.0"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "next"
  },
  "author": "",
  "license": "ISC"
}
$ npm start

> next-play@1.0.0 start /Users/ext.dmosher/code/next-play
> next

> Ready on http://localhost:3000
Warning: Component(...): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.
{ Invariant Violation: Component(...): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.
    at invariant (/Users/ext.dmosher/code/next-play/node_modules/fbjs/lib/invariant.js:38:15)
    at ReactCompositeComponentWrapper.mountComponent (/Users/ext.dmosher/code/next-play/node_modules/react/lib/ReactCompositeComponent.js:194:121)
    at Object.mountComponent (/Users/ext.dmosher/code/next-play/node_modules/react/lib/ReactReconciler.js:47:35)
    at ReactCompositeComponentWrapper.performInitialMount (/Users/ext.dmosher/code/next-play/node_modules/react/lib/ReactCompositeComponent.js:370:34)
    at ReactCompositeComponentWrapper.mountComponent (/Users/ext.dmosher/code/next-play/node_modules/react/lib/ReactCompositeComponent.js:257:21)
    at Object.mountComponent (/Users/ext.dmosher/code/next-play/node_modules/react/lib/ReactReconciler.js:47:35)
    at /Users/ext.dmosher/code/next-play/node_modules/react/lib/ReactServerRendering.js:46:36
    at ReactServerRenderingTransaction.perform (/Users/ext.dmosher/code/next-play/node_modules/react/lib/Transaction.js:138:20)
    at renderToStringImpl (/Users/ext.dmosher/code/next-play/node_modules/react/lib/ReactServerRendering.js:44:24)
    at renderToString (/Users/ext.dmosher/code/next-play/node_modules/react/lib/ReactServerRendering.js:74:10) name: 'Invariant Violation', framesToPop: 1 }
@impronunciable
Copy link
Contributor

@davemo

pages/index.js should be:

import React from 'react'
export default () => (
  <div>Welcome to next.js!</div>
)

() let's you return the expression while {} creates the block and not a return

@davemo
Copy link
Author

davemo commented Oct 25, 2016

@impronunciable ah, thanks, I typed it out instead of copy/pasted and had the wrong parens :(

@impronunciable
Copy link
Contributor

@davemo that's how we learn :)

@lock lock bot locked as resolved and limited conversation to collaborators May 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants