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

Document next/error #1134

Closed
sedubois opened this issue Feb 14, 2017 · 7 comments
Closed

Document next/error #1134

sedubois opened this issue Feb 14, 2017 · 7 comments
Labels
good first issue Easy to fix issues, good for newcomers

Comments

@sedubois
Copy link
Contributor

I don't think it's documented anywhere?

Also (unrelated to title, sorry), I guess it doesn't support any kind of message localization.

@arunoda
Copy link
Contributor

arunoda commented Feb 15, 2017

Yeah! Let's add it.

@arunoda arunoda added the good first issue Easy to fix issues, good for newcomers label Feb 15, 2017
@niksurff
Copy link

niksurff commented Feb 15, 2017

Isn't next/error just the default error page exported by pages/_error.js? It can be overwritten with a custom _error.js and is documented in README.md.

Or am I missing something 😕? Maybe the fact that we can import and render it from any page is what you mean? 💡

Anyways I'll open a PR for #1069 and other documentation improvements, soon. Let me know and I'll add it to the list.

@timneutkens
Copy link
Member

@nikvm #1040

@niksurff
Copy link

Yay, thanks! It's on the list. 🗒

@timneutkens
Copy link
Member

Thank you very much @nikvm 👍

@timneutkens
Copy link
Member

@nikvm added the in progress label.

@timneutkens
Copy link
Member

Something like this should suffice.

import React from 'react'
import Error from 'next/error'
import fetch from 'isomorphic-fetch'

export default class Page extends React.Component {
  static async getInitialProps () {
    const res = await fetch('https://api.github.com/repos/zeit/next.js')
    const statusCode = res.statusCode > 200 ? res.statusCode : false
    const json = await res.json()
    return { statusCode, stars: json.stargazers_count }
  }

  render () {
    if(this.props.statusCode) {
        return <Error statusCode={this.props.statusCode} />
    }

    return (
      <div>Next stars: {this.props.stars}</div>
    )
  }
}

@lock lock bot locked as resolved and limited conversation to collaborators May 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Easy to fix issues, good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants