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

[Example] Remove SSR from with-cerebral #11562

Merged
merged 1 commit into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions examples/with-cerebral/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,11 @@
import React from 'react'
import { Controller, UniversalController } from 'cerebral'
import { Controller } from 'cerebral'
import Devtools from 'cerebral/devtools'
import { Container } from '@cerebral/react'
import Page from '../components/Page'
import clock from '../modules/clock'

export default class Counter extends React.Component {
static getInitialProps({ req }) {
const isServer = Boolean(req)

// On the server we prepare the state of the application. Since
// this is a synchronous state change we just use "setState", but
// you could do other async stuff here or even use "runSequence" to
// grab and set the initial state of the application using
if (isServer) {
const controller = UniversalController({ modules: { clock } })
controller.setState('clock.lastUpdate', Date.now())

return { stateChanges: controller.getChanges() }
}

return {}
}
constructor(props) {
super(props)
// The controller will be instantiated for every page change and we only
Expand Down
18 changes: 1 addition & 17 deletions examples/with-cerebral/pages/other.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,11 @@
import React from 'react'
import { Controller, UniversalController } from 'cerebral'
import { Controller } from 'cerebral'
import Devtools from 'cerebral/devtools'
import { Container } from '@cerebral/react'
import Page from '../components/Page'
import clock from '../modules/clock'

export default class Counter extends React.Component {
static getInitialProps({ req }) {
const isServer = Boolean(req)

// On the server we prepare the state of the application. Since
// this is a synchronous state change we just use "setState", but
// you could do other async stuff here or even use "runSequence" to
// grab and set the initial state of the application using
if (isServer) {
const controller = UniversalController({ modules: { clock } })
controller.setState('clock.lastUpdate', Date.now())

return { stateChanges: controller.getChanges() }
}

return {}
}
constructor(props) {
super(props)
// The controller will be instantiated for every page change and we only
Expand Down