Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
react-live-route
Overview
Overview
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
fukai
react-live-route
Commits
7c637408
Commit
7c637408
authored
May 17, 2019
by
fukai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持新钩子
parent
f75165df
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
2 deletions
+18
-2
LiveRoute.tsx
src/LiveRoute.tsx
+18
-2
No files found.
src/LiveRoute.tsx
View file @
7c637408
...
...
@@ -83,6 +83,7 @@ class LiveRoute extends React.Component<PropsType, any> {
public
previousDisplayStyle
:
string
|
null
=
null
public
liveState
:
LiveState
=
LiveState
.
NORMAL_RENDER_ON_INIT
public
currentSideEffect
:
SideEffect
[]
=
[
SideEffect
.
NO_SIDE_EFFECT
]
public
wrapperedRef
:
any
=
null
public
componentDidMount
()
{
this
.
getRouteDom
()
...
...
@@ -105,10 +106,16 @@ class LiveRoute extends React.Component<PropsType, any> {
this
.
clearScroll
()
}
public
passRef
=
(
ref
)
=>
{
this
.
wrapperedRef
=
ref
}
// get DOM of Route
public
getRouteDom
=
()
=>
{
public
getRouteDom
=
(
ref
?:
any
)
=>
{
let
routeDom
=
ReactDOM
.
findDOMNode
(
this
)
this
.
routeDom
=
(
routeDom
as
CacheDom
)
||
this
.
routeDom
ref
&&
this
.
passRef
(
ref
)
}
public
hideRoute
()
{
...
...
@@ -256,7 +263,7 @@ class LiveRoute extends React.Component<PropsType, any> {
staticContext
// from withRouter, same as RouterContext.Consumer ⬆️
}
=
this
.
props
const
hook
=
this
[
hookName
]
const
hook
=
this
.
props
[
hookName
]
const
context
=
{
history
,
location
,
match
,
staticContext
}
const
matchOfPath
=
this
.
props
.
path
?
matchPath
(
location
.
pathname
,
this
.
props
)
:
context
.
match
const
matchOfLivePath
=
this
.
isLivePathMatch
(
livePath
,
alwaysLive
,
location
!
.
pathname
,
{
...
...
@@ -266,6 +273,15 @@ class LiveRoute extends React.Component<PropsType, any> {
sensitive
})
const
matchAnyway
=
matchOfPath
||
matchOfLivePath
if
(
hookName
==
'onHide'
)
{
this
.
wrapperedRef
&&
this
.
wrapperedRef
.
componentOnHide
&&
this
.
wrapperedRef
.
componentOnHide
(
location
!
,
matchAnyway
,
history
,
livePath
,
alwaysLive
)
}
else
if
(
hookName
==
'onReappear'
)
{
this
.
wrapperedRef
&&
this
.
wrapperedRef
.
componentOnReappear
&&
this
.
wrapperedRef
.
componentOnReappear
(
location
!
,
matchAnyway
,
history
,
livePath
,
alwaysLive
)
}
if
(
typeof
hook
===
'function'
)
{
hook
(
location
!
,
matchAnyway
,
history
,
livePath
,
alwaysLive
)
}
...
...
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