Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
leximpact-client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
leximpact
Simulateur dotations aux communes
leximpact-client
Commits
42e80680
Commit
42e80680
authored
Nov 26, 2020
by
Loïc Poullain
Browse files
Options
Downloads
Patches
Plain Diff
Move withRoot from JS to TS
parent
b170f82f
No related branches found
No related tags found
1 merge request
!118
Convertir les fichiers JS restants en TS (et supprimer JSS)
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/withRoot.tsx
+15
-19
15 additions, 19 deletions
lib/withRoot.tsx
with
15 additions
and
19 deletions
lib/withRoot.
j
sx
→
lib/withRoot.
t
sx
+
15
−
19
View file @
42e80680
import
CssBaseline
from
"
@material-ui/core/CssBaseline
"
;
import
CssBaseline
from
"
@material-ui/core/CssBaseline
"
;
import
{
MuiThemeProvider
}
from
"
@material-ui/core/styles/
"
;
import
{
MuiThemeProvider
}
from
"
@material-ui/core/styles/
"
;
import
PropTypes
from
"
prop-types
"
;
import
React
from
"
react
"
;
import
React
from
"
react
"
;
import
createPageContext
from
"
./createPageContext
"
;
import
createPageContext
from
"
./createPageContext
"
;
...
@@ -8,7 +7,12 @@ import getPageContext from "./getPageContext";
...
@@ -8,7 +7,12 @@ import getPageContext from "./getPageContext";
function
withRoot
(
Component
)
{
function
withRoot
(
Component
)
{
let
pageContext
=
null
;
let
pageContext
=
null
;
class
WithRoot
extends
React
.
Component
{
interface
Props
{
pageContext
:
any
;
}
class
WithRoot
extends
React
.
Component
<
Props
>
{
constructor
(
props
,
context
)
{
constructor
(
props
,
context
)
{
super
(
props
,
context
);
super
(
props
,
context
);
...
@@ -16,12 +20,20 @@ function withRoot(Component) {
...
@@ -16,12 +20,20 @@ function withRoot(Component) {
pageContext
=
propsPageContext
||
getPageContext
(
process
.
browser
,
createPageContext
);
pageContext
=
propsPageContext
||
getPageContext
(
process
.
browser
,
createPageContext
);
}
}
static
getInitialProps
=
(
ctx
)
=>
{
if
(
Component
.
getInitialProps
)
{
return
Component
.
getInitialProps
(
ctx
);
}
return
{};
};
render
()
{
render
()
{
// MuiThemeProvider makes the theme available down the React tree thanks to React
// MuiThemeProvider makes the theme available down the React tree thanks to React
// context.
// context.
return
(
return
(
<
MuiThemeProvider
<
MuiThemeProvider
theme
=
{
pageContext
.
theme
}
>
theme
=
{
(
pageContext
as
any
)
.
theme
}
>
{
/* CssBaseline kickstart an elegant, consistent, and simple baseline to */
}
{
/* CssBaseline kickstart an elegant, consistent, and simple baseline to */
}
{
/* build upon. */
}
{
/* build upon. */
}
<
CssBaseline
/>
<
CssBaseline
/>
...
@@ -31,22 +43,6 @@ function withRoot(Component) {
...
@@ -31,22 +43,6 @@ function withRoot(Component) {
}
}
}
}
WithRoot
.
defaultProps
=
{
pageContext
:
null
,
};
WithRoot
.
propTypes
=
{
pageContext
:
PropTypes
.
shape
(),
};
WithRoot
.
getInitialProps
=
(
ctx
)
=>
{
if
(
Component
.
getInitialProps
)
{
return
Component
.
getInitialProps
(
ctx
);
}
return
{};
};
return
WithRoot
;
return
WithRoot
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment