Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
bf0f9da9
Unverified
Commit
bf0f9da9
authored
Apr 07, 2020
by
Luis Alvarez D
Committed by
GitHub
Apr 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Example] Remove SSR from with-cerebral (#11562)
parent
1239d5af
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
34 deletions
+2
-34
index.js
examples/with-cerebral/pages/index.js
+1
-17
other.js
examples/with-cerebral/pages/other.js
+1
-17
No files found.
examples/with-cerebral/pages/index.js
View file @
bf0f9da9
import
React
from
'react'
import
React
from
'react'
import
{
Controller
,
UniversalController
}
from
'cerebral'
import
{
Controller
}
from
'cerebral'
import
Devtools
from
'cerebral/devtools'
import
Devtools
from
'cerebral/devtools'
import
{
Container
}
from
'@cerebral/react'
import
{
Container
}
from
'@cerebral/react'
import
Page
from
'../components/Page'
import
Page
from
'../components/Page'
import
clock
from
'../modules/clock'
import
clock
from
'../modules/clock'
export
default
class
Counter
extends
React
.
Component
{
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
)
{
constructor
(
props
)
{
super
(
props
)
super
(
props
)
// The controller will be instantiated for every page change and we only
// The controller will be instantiated for every page change and we only
...
...
examples/with-cerebral/pages/other.js
View file @
bf0f9da9
import
React
from
'react'
import
React
from
'react'
import
{
Controller
,
UniversalController
}
from
'cerebral'
import
{
Controller
}
from
'cerebral'
import
Devtools
from
'cerebral/devtools'
import
Devtools
from
'cerebral/devtools'
import
{
Container
}
from
'@cerebral/react'
import
{
Container
}
from
'@cerebral/react'
import
Page
from
'../components/Page'
import
Page
from
'../components/Page'
import
clock
from
'../modules/clock'
import
clock
from
'../modules/clock'
export
default
class
Counter
extends
React
.
Component
{
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
)
{
constructor
(
props
)
{
super
(
props
)
super
(
props
)
// The controller will be instantiated for every page change and we only
// The controller will be instantiated for every page change and we only
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment