Commit e0326600 authored by Corbin Crutchley's avatar Corbin Crutchley Committed by Joe Haddad

form handler example: Update deps and fix build from dep update (#6732)

* form handler example: Update deps and fix build from dep update

* Ran lint error fixers

* Fixes errors that occur when commit occurs

* Commit linter fixes
parent 4fd794e8
...@@ -3,7 +3,11 @@ export default function Layout ({ children }) { ...@@ -3,7 +3,11 @@ export default function Layout ({ children }) {
<> <>
{children} {children}
<style jsx global>{` <style jsx global>{`
body {font-family: Roboto, sans-serif; padding: 30px; color: #444;} body {
font-family: Roboto, sans-serif;
padding: 30px;
color: #444;
}
`}</style> `}</style>
</> </>
) )
......
...@@ -202,9 +202,20 @@ export default () => { ...@@ -202,9 +202,20 @@ export default () => {
for lounge in doorway for chew iPad power cord. for lounge in doorway for chew iPad power cord.
</p> </p>
<style jsx>{` <style jsx>{`
h1 {margin-bottom: 5px;} h1 {
p {font-size: 18px; line-height: 30px; margin-top: 30px;} margin-bottom: 5px;
.caption {color: #ccc; margin-top: 0; font-size: 14px; text-align: center;} }
p {
font-size: 18px;
line-height: 30px;
margin-top: 30px;
}
.caption {
color: #ccc;
margin-top: 0;
font-size: 14px;
text-align: center;
}
`}</style> `}</style>
</Layout> </Layout>
) )
......
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "start": "next start",
"start": "next start -p 8000",
"dev": "node server.js", "dev": "node server.js",
"build": "next build" "build": "next build"
}, },
...@@ -13,14 +12,14 @@ ...@@ -13,14 +12,14 @@
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"express": "^4.15.4", "express": "^4.16.4",
"next": "latest", "next": "latest",
"react": "^16.7.0", "next-redux-wrapper": "^2.1.0",
"react-dom": "^16.7.0", "react": "^16.8.4",
"next-redux-wrapper": "^1.3.2", "react-bootstrap": "^0.32.4",
"react-bootstrap": "^0.31.3", "react-dom": "^16.8.4",
"react-redux": "^5.0.6", "react-redux": "^6.0.1",
"redux": "^3.7.2", "redux": "^4.0.1",
"redux-thunk": "^2.2.0" "redux-thunk": "^2.3.0"
} }
} }
import App, { Container } from 'next/app'
import React from 'react'
import { Provider } from 'react-redux'
import withRedux from 'next-redux-wrapper'
import { initStore } from '../store'
class MyApp extends App {
static async getInitialProps ({ Component, router, ctx }) {
let pageProps = {}
if (Component.getInitialProps) {
pageProps = await Component.getInitialProps(ctx)
}
return { pageProps }
}
render () {
const { Component, pageProps, store } = this.props
return (
<Container>
<Provider store={store}>
<Component {...pageProps} />
</Provider>
</Container>
)
}
}
export default withRedux(initStore)(MyApp)
import React, { Component } from 'react' import React, { Component } from 'react'
import withRedux from 'next-redux-wrapper'
import Main from '../components' import { connect } from 'react-redux'
import { initStore } from '../store' import Main from '../components'
class Index extends Component { class Index extends Component {
render () { render () {
...@@ -11,4 +10,4 @@ class Index extends Component { ...@@ -11,4 +10,4 @@ class Index extends Component {
} }
} }
export default withRedux(initStore, null)(Index) export default connect()(Index)
...@@ -15,7 +15,7 @@ class CounterProvider extends Component { ...@@ -15,7 +15,7 @@ class CounterProvider extends Component {
}) })
} }
increaseBy = (val) => { increaseBy = val => {
this.setState({ this.setState({
count: this.state.count + val count: this.state.count + val
}) })
......
...@@ -13,12 +13,18 @@ export default class about extends Component { ...@@ -13,12 +13,18 @@ export default class about extends Component {
<h1>ABOUT</h1> <h1>ABOUT</h1>
<p>Counter: {count}</p> <p>Counter: {count}</p>
<button onClick={increase}>Increase</button> <button onClick={increase}>Increase</button>
<button onClick={() => { <button
increaseBy(15) onClick={() => {
}}>Increase By 15</button> increaseBy(15)
<p><Link href='/'> }}
<a>Home</a> >
</Link></p> Increase By 15
</button>
<p>
<Link href='/'>
<a>Home</a>
</Link>
</p>
</div> </div>
)} )}
</CounterConsumer> </CounterConsumer>
......
...@@ -14,9 +14,11 @@ export default class index extends Component { ...@@ -14,9 +14,11 @@ export default class index extends Component {
<p>Counter: {count}</p> <p>Counter: {count}</p>
<button onClick={increase}>Increase</button> <button onClick={increase}>Increase</button>
<button onClick={decrease}>Decrease</button> <button onClick={decrease}>Decrease</button>
<p><Link href='/about'> <p>
<a>About</a> <Link href='/about'>
</Link></p> <a>About</a>
</Link>
</p>
</div> </div>
)} )}
</CounterConsumer> </CounterConsumer>
......
...@@ -3,7 +3,10 @@ const functions = require('firebase-functions') ...@@ -3,7 +3,10 @@ const functions = require('firebase-functions')
const next = require('next') const next = require('next')
var dev = process.env.NODE_ENV !== 'production' var dev = process.env.NODE_ENV !== 'production'
var app = next({ dev, conf: { distDir: `${path.relative(process.cwd(), __dirname)}/next` } }) var app = next({
dev,
conf: { distDir: `${path.relative(process.cwd(), __dirname)}/next` }
})
var handle = app.getRequestHandler() var handle = app.getRequestHandler()
exports.next = functions.https.onRequest((req, res) => { exports.next = functions.https.onRequest((req, res) => {
......
...@@ -5,14 +5,16 @@ export default () => { ...@@ -5,14 +5,16 @@ export default () => {
fetchOptionsOverride (options) { fetchOptionsOverride (options) {
options.url = 'https://graphql-pokemon.now.sh' options.url = 'https://graphql-pokemon.now.sh'
}, },
operation: { query: ` operation: {
query: `
{ {
pokemon(name: "Pikachu") { pokemon(name: "Pikachu") {
name name
image image
} }
} }
` } `
}
}) })
const { data } = cacheValue const { data } = cacheValue
......
...@@ -15,7 +15,12 @@ export default class MyDocument extends Document { ...@@ -15,7 +15,12 @@ export default class MyDocument extends Document {
const initialProps = await Document.getInitialProps(ctx) const initialProps = await Document.getInitialProps(ctx)
return { return {
...initialProps, ...initialProps,
styles: <>{initialProps.styles}{sheet.getStyleElement()}</> styles: (
<>
{initialProps.styles}
{sheet.getStyleElement()}
</>
)
} }
} finally { } finally {
sheet.seal() sheet.seal()
......
...@@ -5,7 +5,8 @@ export default () => ( ...@@ -5,7 +5,8 @@ export default () => (
<Box align='center' margin='large'> <Box align='center' margin='large'>
<Heading>Grommet is awesome!</Heading> <Heading>Grommet is awesome!</Heading>
<Paragraph> <Paragraph>
Find out more at <Anchor href='https://v2.grommet.io/'>https://v2.grommet.io/</Anchor> Find out more at{' '}
<Anchor href='https://v2.grommet.io/'>https://v2.grommet.io/</Anchor>
</Paragraph> </Paragraph>
</Box> </Box>
) )
...@@ -27,9 +27,7 @@ export default () => { ...@@ -27,9 +27,7 @@ export default () => {
<Head> <Head>
<title>With Linaria</title> <title>With Linaria</title>
</Head> </Head>
<Box> <Box>Zero runtime CSS in JS</Box>
Zero runtime CSS in JS
</Box>
</React.Fragment> </React.Fragment>
) )
} }
...@@ -3,8 +3,8 @@ import { I18n } from '@lingui/react' ...@@ -3,8 +3,8 @@ import { I18n } from '@lingui/react'
import { t, Trans } from '@lingui/macro' import { t, Trans } from '@lingui/macro'
const availableLanguageNames = { const availableLanguageNames = {
'en': t`English`, en: t`English`,
'sv': t`Swedish` sv: t`Swedish`
} }
const availableLanguages = Object.keys(availableLanguageNames) const availableLanguages = Object.keys(availableLanguageNames)
...@@ -18,15 +18,27 @@ export default () => { ...@@ -18,15 +18,27 @@ export default () => {
} }
return ( return (
<I18n>{({ i18n }) => <I18n>
<form onSubmit={onSubmit}> {({ i18n }) => (
<select key={i18n.language} name='lang' defaultValue={availableLanguages.find(lang => lang !== i18n.language)}> <form onSubmit={onSubmit}>
{availableLanguages.map(lang => ( <select
<option key={lang} value={lang} disabled={i18n.language === lang}>{i18n._(availableLanguageNames[lang])}</option> key={i18n.language}
))} name='lang'
</select> defaultValue={availableLanguages.find(
<button><Trans>Switch language</Trans></button> lang => lang !== i18n.language
</form> )}
}</I18n> >
{availableLanguages.map(lang => (
<option key={lang} value={lang} disabled={i18n.language === lang}>
{i18n._(availableLanguageNames[lang])}
</option>
))}
</select>
<button>
<Trans>Switch language</Trans>
</button>
</form>
)}
</I18n>
) )
} }
import React from 'react' import React from 'react'
import { I18nProvider } from '@lingui/react' import { I18nProvider } from '@lingui/react'
export default (Component, defaultLang = 'en') => class WithLang extends React.Component { export default (Component, defaultLang = 'en') =>
static async getInitialProps (ctx) { class WithLang extends React.Component {
const language = ctx.query.lang || defaultLang static async getInitialProps (ctx) {
const [props, catalog] = await Promise.all([ const language = ctx.query.lang || defaultLang
Component.getInitialProps ? Component.getInitialProps(ctx) : {}, const [props, catalog] = await Promise.all([
import(`../locale/${language}/messages.po`).then(m => m.default) Component.getInitialProps ? Component.getInitialProps(ctx) : {},
]) import(`../locale/${language}/messages.po`).then(m => m.default)
])
return { return {
...props, ...props,
language, language,
catalogs: { catalogs: {
[language]: catalog [language]: catalog
}
} }
} }
}
render () { render () {
return ( return (
<I18nProvider language={this.props.language} catalogs={this.props.catalogs}> <I18nProvider
<Component /> language={this.props.language}
</I18nProvider> catalogs={this.props.catalogs}
) >
<Component />
</I18nProvider>
)
}
} }
}
...@@ -3,12 +3,17 @@ import { Trans } from '@lingui/macro' ...@@ -3,12 +3,17 @@ import { Trans } from '@lingui/macro'
import withLang from '../components/withLang' import withLang from '../components/withLang'
import LangSwitcher from '../components/LangSwitcher' import LangSwitcher from '../components/LangSwitcher'
const Index = () => const Index = () => (
<div> <div>
<Trans>Hello World.</Trans> <Trans>Hello World.</Trans>
<Link href='/two'><a><Trans>Go to page 2</Trans></a></Link> <Link href='/two'>
<a>
<Trans>Go to page 2</Trans>
</a>
</Link>
<br /> <br />
<LangSwitcher /> <LangSwitcher />
</div> </div>
)
export default withLang(Index) export default withLang(Index)
...@@ -2,11 +2,12 @@ import { Trans } from '@lingui/macro' ...@@ -2,11 +2,12 @@ import { Trans } from '@lingui/macro'
import withLang from '../components/withLang' import withLang from '../components/withLang'
import LangSwitcher from '../components/LangSwitcher' import LangSwitcher from '../components/LangSwitcher'
const Two = () => const Two = () => (
<div> <div>
<Trans>Page two. </Trans> <Trans>Page two. </Trans>
<br /> <br />
<LangSwitcher /> <LangSwitcher />
</div> </div>
)
export default withLang(Two) export default withLang(Two)
...@@ -12,18 +12,19 @@ function Page ({ linkTo, title }) { ...@@ -12,18 +12,19 @@ function Page ({ linkTo, title }) {
return stop return stop
}, []) }, [])
return <div> return (
<h1>{title}</h1> <div>
{useObserver(() => <Clock <h1>{title}</h1>
lastUpdate={store.lastUpdate} {useObserver(() => (
light={store.light} <Clock lastUpdate={store.lastUpdate} light={store.light} />
/>)} ))}
<nav> <nav>
<Link href={linkTo}> <Link href={linkTo}>
<a>Navigate</a> <a>Navigate</a>
</Link> </Link>
</nav> </nav>
</div> </div>
)
} }
export default Page export default Page
...@@ -21,7 +21,7 @@ class MyMobxApp extends App { ...@@ -21,7 +21,7 @@ class MyMobxApp extends App {
constructor(props) { constructor(props) {
super(props) super(props)
const isServer = !process.browser; const isServer = !process.browser
this.mobxStore = isServer this.mobxStore = isServer
? props.initialMobxState ? props.initialMobxState
: initializeStore(props.initialMobxState) : initializeStore(props.initialMobxState)
......
...@@ -35,7 +35,11 @@ export default () => ( ...@@ -35,7 +35,11 @@ export default () => (
<h1>SEO Added to Page</h1> <h1>SEO Added to Page</h1>
<p>Take a look at the head to see what has been added.</p> <p>Take a look at the head to see what has been added.</p>
<p> <p>
Or checkout how <Link href='/jsonld'><a>JSON-LD</a></Link> (Structured Data) is added Or checkout how{' '}
<Link href='/jsonld'>
<a>JSON-LD</a>
</Link>{' '}
(Structured Data) is added
</p> </p>
</div> </div>
) )
export default () => ( export default () => (
<div className='hello'> <div className='hello'>
<p> <p>
Hello World! Here's a secret shared with the client using Next env: <strong>{process.env.SECRET}</strong>, the secret is shared Hello World! Here's a secret shared with the client using Next env:{' '}
at compile time, which means every reference to the secret is replaced <strong>{process.env.SECRET}</strong>, the secret is shared at compile
with its value time, which means every reference to the secret is replaced with its value
</p> </p>
<style jsx>{` <style jsx>{`
.hello { .hello {
......
import { useState } from 'react' import { useState } from 'react'
import { Fabric } from 'office-ui-fabric-react/lib-commonjs/Fabric' import { Fabric } from 'office-ui-fabric-react/lib-commonjs/Fabric'
import { DefaultButton, PrimaryButton } from 'office-ui-fabric-react/lib-commonjs/Button' import {
import { Dialog, DialogType, DialogFooter } from 'office-ui-fabric-react/lib-commonjs/Dialog' DefaultButton,
PrimaryButton
} from 'office-ui-fabric-react/lib-commonjs/Button'
import {
Dialog,
DialogType,
DialogFooter
} from 'office-ui-fabric-react/lib-commonjs/Dialog'
export default () => { export default () => {
const [isOpen, setIsOpen] = useState(false) const [isOpen, setIsOpen] = useState(false)
...@@ -10,7 +17,9 @@ export default () => { ...@@ -10,7 +17,9 @@ export default () => {
return ( return (
<Fabric> <Fabric>
<p>Welcome to next.js!</p> <p>Welcome to next.js!</p>
<DefaultButton primary onClick={openDialog}>Open Dialog</DefaultButton> <DefaultButton primary onClick={openDialog}>
Open Dialog
</DefaultButton>
<Dialog <Dialog
hidden={!isOpen} hidden={!isOpen}
onDismiss={closeDialog} onDismiss={closeDialog}
......
...@@ -15,7 +15,12 @@ export default class MyDocument extends Document { ...@@ -15,7 +15,12 @@ export default class MyDocument extends Document {
const initialProps = await Document.getInitialProps(ctx) const initialProps = await Document.getInitialProps(ctx)
return { return {
...initialProps, ...initialProps,
styles: <>{initialProps.styles}{sheet.getStyleElement()}</> styles: (
<>
{initialProps.styles}
{sheet.getStyleElement()}
</>
)
} }
} finally { } finally {
sheet.seal() sheet.seal()
......
...@@ -4,7 +4,9 @@ import { Alert, Illustration } from '@kiwicom/orbit-components' ...@@ -4,7 +4,9 @@ import { Alert, Illustration } from '@kiwicom/orbit-components'
export default () => { export default () => {
return ( return (
<React.Fragment> <React.Fragment>
<Alert type='success' spaceAfter='large'>It Works!</Alert> <Alert type='success' spaceAfter='large'>
It Works!
</Alert>
<Illustration name='Success' /> <Illustration name='Success' />
</React.Fragment> </React.Fragment>
) )
......
...@@ -6,9 +6,9 @@ function Items () { ...@@ -6,9 +6,9 @@ function Items () {
return ( return (
<ul> <ul>
{state.items.map((item) => {state.items.map(item => (
<li key={item.id}>{item.title}</li> <li key={item.id}>{item.title}</li>
)} ))}
</ul> </ul>
) )
} }
......
...@@ -13,13 +13,16 @@ class Index extends React.Component { ...@@ -13,13 +13,16 @@ class Index extends React.Component {
const overmind = createOvermindSSR(config) const overmind = createOvermindSSR(config)
overmind.state.page = 'Index' overmind.state.page = 'Index'
overmind.state.items = [{ overmind.state.items = [
id: 0, {
title: 'foo' id: 0,
}, { title: 'foo'
id: 1, },
title: 'bar' {
}] id: 1,
title: 'bar'
}
]
return { return {
mutations: overmind.hydrate() mutations: overmind.hydrate()
......
...@@ -30,26 +30,33 @@ export default class Index extends React.Component { ...@@ -30,26 +30,33 @@ export default class Index extends React.Component {
</button> </button>
{this.state.opened && ( {this.state.opened && (
<UniversalPortal selector='#modal'> <UniversalPortal selector='#modal'>
<div style={{ <div
position: 'fixed', style={{
backgroundColor: 'rgba(0, 0, 0, 0.7)', position: 'fixed',
top: 0, backgroundColor: 'rgba(0, 0, 0, 0.7)',
right: 0, top: 0,
bottom: 0, right: 0,
left: 0 bottom: 0,
}}> left: 0
<div style={{ }}
backgroundColor: 'white', >
position: 'absolute', <div
top: '10%', style={{
right: '10%', backgroundColor: 'white',
bottom: '10%', position: 'absolute',
left: '10%', top: '10%',
padding: '1em' right: '10%',
}}> bottom: '10%',
left: '10%',
padding: '1em'
}}
>
<p> <p>
This modal is rendered using{' '} This modal is rendered using{' '}
<a href='https://www.npmjs.com/package/@jesstelford/react-portal-universal'><code>@jesstelford/react-portal-universal</code></a>. <a href='https://www.npmjs.com/package/@jesstelford/react-portal-universal'>
<code>@jesstelford/react-portal-universal</code>
</a>
.
</p> </p>
<button type='button' onClick={this.close}> <button type='button' onClick={this.close}>
Close Modal Close Modal
......
...@@ -22,7 +22,10 @@ export default class MyApp extends App { ...@@ -22,7 +22,10 @@ export default class MyApp extends App {
htmlAttributes={{ lang: 'en' }} htmlAttributes={{ lang: 'en' }}
title='Hello next.js!' title='Hello next.js!'
meta={[ meta={[
{ name: 'viewport', content: 'width=device-width, initial-scale=1' }, {
name: 'viewport',
content: 'width=device-width, initial-scale=1'
},
{ property: 'og:title', content: 'Hello next.js!' } { property: 'og:title', content: 'Hello next.js!' }
]} ]}
/> />
......
...@@ -29,9 +29,7 @@ export default class extends Document { ...@@ -29,9 +29,7 @@ export default class extends Document {
render () { render () {
return ( return (
<html {...this.helmetHtmlAttrComponents}> <html {...this.helmetHtmlAttrComponents}>
<Head> <Head>{this.helmetHeadComponents}</Head>
{this.helmetHeadComponents}
</Head>
<body {...this.helmetBodyAttrComponents}> <body {...this.helmetBodyAttrComponents}>
<Main /> <Main />
<NextScript /> <NextScript />
......
...@@ -20,12 +20,12 @@ export default class JssDocument extends Document { ...@@ -20,12 +20,12 @@ export default class JssDocument extends Document {
return { return {
...initialProps, ...initialProps,
styles: <> styles: (
{initialProps.styles} <>
<style id='server-side-styles'> {initialProps.styles}
{registry.toString()} <style id='server-side-styles'>{registry.toString()}</style>
</style> </>
</> )
} }
} }
} }
...@@ -38,6 +38,10 @@ function mapStateToProps (state) { ...@@ -38,6 +38,10 @@ function mapStateToProps (state) {
const { count } = state const { count } = state
return { count } return { count }
} }
const mapDispatchToProps = dispatch => bindActionCreators({ incrementCount, decrementCount, resetCount }, dispatch) const mapDispatchToProps = dispatch =>
bindActionCreators({ incrementCount, decrementCount, resetCount }, dispatch)
export default connect(mapStateToProps, mapDispatchToProps)(Counter) export default connect(
mapStateToProps,
mapDispatchToProps
)(Counter)
...@@ -27,4 +27,7 @@ class Index extends React.Component { ...@@ -27,4 +27,7 @@ class Index extends React.Component {
} }
} }
const mapDispatchToProps = { startClock } const mapDispatchToProps = { startClock }
export default connect(null, mapDispatchToProps)(Index) export default connect(
null,
mapDispatchToProps
)(Index)
...@@ -44,7 +44,9 @@ export default (ComposedComponent, options = {}) => { ...@@ -44,7 +44,9 @@ export default (ComposedComponent, options = {}) => {
render () { render () {
return ( return (
<ReactRelayContext.Provider value={{ environment: this.environment, variables: {} }}> <ReactRelayContext.Provider
value={{ environment: this.environment, variables: {} }}
>
<ComposedComponent {...this.props} /> <ComposedComponent {...this.props} />
</ReactRelayContext.Provider> </ReactRelayContext.Provider>
) )
......
...@@ -46,7 +46,9 @@ export default (ComposedComponent, options = {}) => { ...@@ -46,7 +46,9 @@ export default (ComposedComponent, options = {}) => {
render () { render () {
return ( return (
<ReactRelayContext.Provider value={{ environment: this.environment, variables: {} }}> <ReactRelayContext.Provider
value={{ environment: this.environment, variables: {} }}
>
<ComposedComponent {...this.props} /> <ComposedComponent {...this.props} />
</ReactRelayContext.Provider> </ReactRelayContext.Provider>
) )
......
...@@ -7,10 +7,11 @@ Router.events.on('routeChangeComplete', url => { ...@@ -7,10 +7,11 @@ Router.events.on('routeChangeComplete', url => {
window.analytics.page(url) window.analytics.page(url)
}) })
const Page = ({ children }) => const Page = ({ children }) => (
<div> <div>
<Header /> <Header />
{children} {children}
</div> </div>
)
export default Page export default Page
import 'semantic-ui-css/semantic.min.css' import 'semantic-ui-css/semantic.min.css'
import { Modal, import { Modal, Button, Icon } from 'semantic-ui-react'
Button,
Icon
} from 'semantic-ui-react'
import SmallImage from './SmallImage.png' import SmallImage from './SmallImage.png'
import LargeImage from './LargeImage.png' import LargeImage from './LargeImage.png'
...@@ -13,24 +10,26 @@ export default () => ( ...@@ -13,24 +10,26 @@ export default () => (
<Icon size='massive' name='world' /> <Icon size='massive' name='world' />
<div className='separator' /> <div className='separator' />
<Modal trigger={<Button>Show Modal</Button>}> <Modal trigger={<Button>Show Modal</Button>}>
<Modal.Header><em>publicPath</em> should be set to <em>/_next/static/</em></Modal.Header> <Modal.Header>
<em>publicPath</em> should be set to <em>/_next/static/</em>
</Modal.Header>
<Modal.Content> <Modal.Content>
<Modal.Description> <Modal.Description>
<div className='wrapper'> <div className='wrapper'>
<div className='row'> <div className='row'>
<p> <p>
Larger content should be still availble as a fallback Larger content should be still availble as a fallback to{' '}
to <em>fileLoader</em> but <em>fileLoader</em> but it should not polute{' '}
it should not polute <em>/.next/static/css</em> folder. <em>/.next/static/css</em> folder. You should see two images
You should see two images below. below. One, smaller, loaded as data url, and one, bigger, loaded
One, smaller, loaded as data url, and one, bigger, loaded
via url. via url.
</p> </p>
</div> </div>
<div className='row'> <div className='row'>
<img src={SmallImage} /> <img src={SmallImage} />
<p> <p>
A small image should be loaded as data url: <em>{SmallImage.substr(0, 100)}...</em> A small image should be loaded as data url:{' '}
<em>{SmallImage.substr(0, 100)}...</em>
</p> </p>
</div> </div>
...@@ -41,8 +40,8 @@ export default () => ( ...@@ -41,8 +40,8 @@ export default () => (
</p> </p>
</div> </div>
<p className='border'> <p className='border'>
You should also still be able to load regular css. You should also still be able to load regular css. This text
This text should have border. should have border.
</p> </p>
</div> </div>
</Modal.Description> </Modal.Description>
......
...@@ -62,7 +62,9 @@ export default class MyApp extends App { ...@@ -62,7 +62,9 @@ export default class MyApp extends App {
<p> <p>
<a <a
href='#' href='#'
onClick={() => Sentry.showReportDialog({ eventId: this.state.errorEventId })} onClick={() =>
Sentry.showReportDialog({ eventId: this.state.errorEventId })
}
> >
📣 Report this error 📣 Report this error
</a> </a>
...@@ -70,7 +72,9 @@ export default class MyApp extends App { ...@@ -70,7 +72,9 @@ export default class MyApp extends App {
<p> <p>
<a <a
href='#' href='#'
onClick={() => { window.location.reload(true) }} onClick={() => {
window.location.reload(true)
}}
> >
Or, try reloading the page Or, try reloading the page
</a> </a>
......
...@@ -30,8 +30,16 @@ class Index extends React.Component { ...@@ -30,8 +30,16 @@ class Index extends React.Component {
<div> <div>
<h2>Index page</h2> <h2>Index page</h2>
<ul> <ul>
<li><a href='#' onClick={this.raiseErrorInRender}>Raise the error in render</a></li> <li>
<li><a href='#' onClick={this.raiseErrorInUpdate}>Raise the error in componentDidUpdate</a></li> <a href='#' onClick={this.raiseErrorInRender}>
Raise the error in render
</a>
</li>
<li>
<a href='#' onClick={this.raiseErrorInUpdate}>
Raise the error in componentDidUpdate
</a>
</li>
<li> <li>
<Link href={{ pathname: '/', query: { raiseError: '1' } }}> <Link href={{ pathname: '/', query: { raiseError: '1' } }}>
<a>Raise error in getInitialProps of client-loaded page</a> <a>Raise error in getInitialProps of client-loaded page</a>
......
...@@ -21,10 +21,12 @@ module.exports = (release = process.env.SENTRY_RELEASE) => { ...@@ -21,10 +21,12 @@ module.exports = (release = process.env.SENTRY_RELEASE) => {
sentryOptions.transport = sentryTransport sentryOptions.transport = sentryTransport
// Instead, dump the errors to the console // Instead, dump the errors to the console
sentryOptions.integrations = [new Sentry.Integrations.Debug({ sentryOptions.integrations = [
// Trigger DevTools debugger instead of using console.log new Sentry.Integrations.Debug({
debugger: false // Trigger DevTools debugger instead of using console.log
})] debugger: false
})
]
} }
Sentry.init(sentryOptions) Sentry.init(sentryOptions)
...@@ -32,7 +34,7 @@ module.exports = (release = process.env.SENTRY_RELEASE) => { ...@@ -32,7 +34,7 @@ module.exports = (release = process.env.SENTRY_RELEASE) => {
return { return {
Sentry, Sentry,
captureException: (err, ctx) => { captureException: (err, ctx) => {
Sentry.configureScope((scope) => { Sentry.configureScope(scope => {
if (err.message) { if (err.message) {
// De-duplication currently doesn't work correctly for SSR / browser errors // De-duplication currently doesn't work correctly for SSR / browser errors
// so we force deduplication by error message if it is present // so we force deduplication by error message if it is present
...@@ -75,7 +77,9 @@ module.exports = (release = process.env.SENTRY_RELEASE) => { ...@@ -75,7 +77,9 @@ module.exports = (release = process.env.SENTRY_RELEASE) => {
} }
if (errorInfo) { if (errorInfo) {
Object.keys(errorInfo).forEach(key => scope.setExtra(key, errorInfo[key])) Object.keys(errorInfo).forEach(key =>
scope.setExtra(key, errorInfo[key])
)
} }
} }
}) })
......
...@@ -15,7 +15,13 @@ class CustomKeygenEditor extends React.Component { ...@@ -15,7 +15,13 @@ class CustomKeygenEditor extends React.Component {
this.initialValue = Plain.deserialize(props.content) this.initialValue = Plain.deserialize(props.content)
} }
render () { render () {
return <Editor placeholder='Enter some plain text...' defaultValue={this.initialValue} style={this.props.style} /> return (
<Editor
placeholder='Enter some plain text...'
defaultValue={this.initialValue}
style={this.props.style}
/>
)
} }
} }
......
...@@ -3,7 +3,8 @@ import Link from 'next/link' ...@@ -3,7 +3,8 @@ import Link from 'next/link'
import CustomKeygenEditor from './CustomKeygenEditor' import CustomKeygenEditor from './CustomKeygenEditor'
const content = { const content = {
'first-editor': 'This example shows how to have multiple instances of the editor.', 'first-editor':
'This example shows how to have multiple instances of the editor.',
'second-editor': 'Without a custom key generator, you could not focus here.' 'second-editor': 'Without a custom key generator, you could not focus here.'
} }
...@@ -15,7 +16,12 @@ class MultipleEditors extends React.Component { ...@@ -15,7 +16,12 @@ class MultipleEditors extends React.Component {
<a>Go to Home</a> <a>Go to Home</a>
</Link> </Link>
{Object.keys(content).map((key, idx) => ( {Object.keys(content).map((key, idx) => (
<CustomKeygenEditor key={idx} uniqueId={key} content={content[key]} style={{ margin: 20 }} /> <CustomKeygenEditor
key={idx}
uniqueId={key}
content={content[key]}
style={{ margin: 20 }}
/>
))} ))}
</React.Fragment> </React.Fragment>
) )
......
...@@ -15,7 +15,12 @@ export default class MyDocument extends Document { ...@@ -15,7 +15,12 @@ export default class MyDocument extends Document {
const initialProps = await Document.getInitialProps(ctx) const initialProps = await Document.getInitialProps(ctx)
return { return {
...initialProps, ...initialProps,
styles: <>{initialProps.styles}{sheet.getStyleElement()}</> styles: (
<>
{initialProps.styles}
{sheet.getStyleElement()}
</>
)
} }
} finally { } finally {
sheet.seal() sheet.seal()
......
export default () => ( export default () => (
<div> <div>
<p>Environment variable process.env.TEST is "{process.env.TEST}"</p> <p>Environment variable process.env.TEST is "{process.env.TEST}"</p>
<p>Custom environment variables process.env.BACKEND_URL is "{process.env.BACKEND_URL}"</p> <p>
Custom environment variables process.env.BACKEND_URL is "
{process.env.BACKEND_URL}"
</p>
</div> </div>
) )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment