Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
d0dc7a65
Commit
d0dc7a65
authored
10 months ago
by
Loïc Correnson
Browse files
Options
Downloads
Patches
Plain Diff
[dome/errors] upgrade to new React API
parent
c8670e77
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ivette/src/dome/renderer/errors.tsx
+16
-8
16 additions, 8 deletions
ivette/src/dome/renderer/errors.tsx
with
16 additions
and
8 deletions
ivette/src/dome/renderer/errors.tsx
+
16
−
8
View file @
d0dc7a65
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
*/
*/
import
React
,
{
ReactNode
}
from
'
react
'
;
import
React
,
{
ReactNode
}
from
'
react
'
;
import
{
Debug
}
from
'
dome
'
;
import
{
DEVEL
,
Debug
}
from
'
dome
'
;
import
{
Label
}
from
'
dome/controls/labels
'
;
import
{
Label
}
from
'
dome/controls/labels
'
;
import
{
Button
}
from
'
dome/controls/buttons
'
;
import
{
Button
}
from
'
dome/controls/buttons
'
;
...
@@ -53,7 +53,6 @@ export interface CatchProps {
...
@@ -53,7 +53,6 @@ export interface CatchProps {
label
?:
string
;
label
?:
string
;
/** Alternative renderer callback in case of errors. */
/** Alternative renderer callback in case of errors. */
onError
?:
JSX
.
Element
|
ErrorRenderer
;
onError
?:
JSX
.
Element
|
ErrorRenderer
;
children
:
ReactNode
;
children
:
ReactNode
;
}
}
...
@@ -62,25 +61,34 @@ interface CatchState {
...
@@ -62,25 +61,34 @@ interface CatchState {
info
?:
unknown
;
info
?:
unknown
;
}
}
/* eslint-disable react/prop-types */
/**
/**
React Error Boundaries.
React Error Boundaries.
*/
*/
export
class
Catch
extends
React
.
Component
<
CatchProps
,
CatchState
,
unknown
>
{
export
class
Catch
extends
React
.
Component
<
CatchProps
,
CatchState
,
unknown
>
{
constructor
(
pr
ivate
p
:
CatchProps
)
{
constructor
(
pr
ops
:
CatchProps
)
{
super
(
p
);
super
(
p
rops
);
this
.
state
=
{};
this
.
state
=
{};
this
.
logerr
=
this
.
logerr
.
bind
(
this
);
this
.
logerr
=
this
.
logerr
.
bind
(
this
);
this
.
reload
=
this
.
reload
.
bind
(
this
);
this
.
reload
=
this
.
reload
.
bind
(
this
);
}
}
componentDidCatch
(
error
:
unknown
,
info
:
unknown
):
void
{
componentDidCatch
(
error
:
unknown
,
info
:
unknown
):
void
{
this
.
setState
({
error
,
info
});
if
(
DEVEL
)
{
const
{
label
=
'
Error
'
}
=
this
.
props
;
D
.
error
(
label
,
'
:
'
,
error
,
info
);
}
}
static
getDerivedStateFromError
(
error
:
unknown
,
info
:
unknown
):
CatchState
{
return
{
error
,
info
};
}
}
logerr
():
void
{
logerr
():
void
{
const
{
error
,
info
}
=
this
.
state
;
const
{
error
,
info
}
=
this
.
state
;
D
.
error
(
'
c
atched error:
'
,
error
,
info
);
D
.
error
(
'
C
atched error:
'
,
error
,
info
);
}
}
reload
():
void
{
reload
():
void
{
...
@@ -89,7 +97,7 @@ export class Catch extends React.Component<CatchProps, CatchState, unknown> {
...
@@ -89,7 +97,7 @@ export class Catch extends React.Component<CatchProps, CatchState, unknown> {
render
():
JSX
.
Element
{
render
():
JSX
.
Element
{
const
{
error
,
info
}
=
this
.
state
;
const
{
error
,
info
}
=
this
.
state
;
const
{
onError
,
label
=
'
Error
'
}
=
this
.
p
;
const
{
onError
,
label
=
'
Error
'
}
=
this
.
p
rops
;
if
(
error
)
{
if
(
error
)
{
if
(
typeof
onError
===
'
function
'
)
if
(
typeof
onError
===
'
function
'
)
return
onError
(
error
,
info
,
this
.
reload
);
return
onError
(
error
,
info
,
this
.
reload
);
...
@@ -106,7 +114,7 @@ export class Catch extends React.Component<CatchProps, CatchState, unknown> {
...
@@ -106,7 +114,7 @@ export class Catch extends React.Component<CatchProps, CatchState, unknown> {
</
div
>
</
div
>
);
);
}
}
return
(<>
{
this
.
p
.
children
}
</>);
return
(<>
{
this
.
p
rops
.
children
}
</>);
}
}
}
}
...
...
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