Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
react-keep-alive
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Administrator
react-keep-alive
Commits
656db95d
Commit
656db95d
authored
Mar 12, 2019
by
Shen Chang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(Fix KeepAlive not in Provider without prompting):
parent
0d0407e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
10 deletions
+12
-10
src/components/Consumer.tsx
src/components/Consumer.tsx
+0
-10
src/utils/keepAlive.tsx
src/utils/keepAlive.tsx
+12
-0
No files found.
src/components/Consumer.tsx
View file @
656db95d
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
Comment
from
'
./Comment
'
;
import
Comment
from
'
./Comment
'
;
import
{
LIFECYCLE
,
ICache
,
ICacheItem
}
from
'
./Provider
'
;
import
{
LIFECYCLE
,
ICache
,
ICacheItem
}
from
'
./Provider
'
;
import
{
warn
}
from
'
../utils/debug
'
;
import
findDOMNodeByFiberNode
from
'
../utils/findDOMNodeByFiberNode
'
;
import
findDOMNodeByFiberNode
from
'
../utils/findDOMNodeByFiberNode
'
;
interface
IConsumerProps
{
interface
IConsumerProps
{
...
@@ -18,15 +17,6 @@ class Consumer extends React.PureComponent<IConsumerProps> {
...
@@ -18,15 +17,6 @@ class Consumer extends React.PureComponent<IConsumerProps> {
private
identification
:
string
=
this
.
props
.
identification
;
private
identification
:
string
=
this
.
props
.
identification
;
constructor
(
props
:
IConsumerProps
,
...
args
:
any
)
{
super
(
props
,
...
args
);
const
{
cache
,
setCache
,
children
}
=
props
;
if
(
!
cache
||
!
setCache
)
{
warn
(
'
[React Keep Alive] You should not use <KeepAlive> outside a <Provider>.
'
);
}
React
.
Children
.
only
(
children
);
}
public
componentDidMount
()
{
public
componentDidMount
()
{
const
{
const
{
setCache
,
setCache
,
...
...
src/utils/keepAlive.tsx
View file @
656db95d
...
@@ -173,6 +173,18 @@ export default function keepAliveDecorator<P = any>(Component: React.ComponentTy
...
@@ -173,6 +173,18 @@ export default function keepAliveDecorator<P = any>(Component: React.ComponentTy
private
lifecycle
=
LIFECYCLE
.
MOUNTED
;
private
lifecycle
=
LIFECYCLE
.
MOUNTED
;
constructor
(
props
:
ITriggerLifecycleContainerProps
,
...
args
:
any
)
{
super
(
props
,
...
args
);
const
{
_keepAliveContextProps
:
{
cache
,
},
}
=
props
;
if
(
!
cache
)
{
warn
(
'
[React Keep Alive] You should not use <KeepAlive> outside a <Provider>.
'
);
}
}
public
componentDidMount
()
{
public
componentDidMount
()
{
if
(
!
this
.
ifStillActivate
)
{
if
(
!
this
.
ifStillActivate
)
{
this
.
activate
();
this
.
activate
();
...
...
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