Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32158993
root-context.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
root-context.js
View Options
// @flow
import
type
{
GenericNavigationAction
}
from
'@react-navigation/native'
;
import
*
as
React
from
'react'
;
import
hoistNonReactStatics
from
'hoist-non-react-statics'
;
import
PropTypes
from
'prop-types'
;
export
type
RootContextType
=
{
|
detectUnsupervisedBackground
?:
?
(
alreadyClosed
:
boolean
)
=>
boolean
,
setNavStateInitialized
:
()
=>
void
,
onNavAction
:
(
action
:
GenericNavigationAction
|
string
)
=>
void
,
|
};
const
RootContext
=
React
.
createContext
<?
RootContextType
>
(
null
);
function
withRootContext
<
AllProps
:
{},
ComponentType
:
React
.
ComponentType
<
AllProps
>
,
>
(
Component
:
ComponentType
,
)
:
React
.
ComponentType
<
$Diff
<
React
.
ElementConfig
<
ComponentType
>
,
{
rootContext
:
?
RootContextType
}
>
,
>
&
ComponentType
{
function
RootContextHOC
(
props
:
$Diff
<
React
.
ElementConfig
<
ComponentType
>
,
{
rootContext
:
?
RootContextType
},
>
,
)
{
return
(
<
RootContext
.
Consumer
>
{
value
=>
<
Component
{...
props
}
rootContext
=
{
value
}
/>
}
<
/RootContext.Consumer>
);
}
const
MemoizedRootContextHOC
=
React
.
memo
(
RootContextHOC
);
hoistNonReactStatics
(
MemoizedRootContextHOC
,
Component
);
// $FlowFixMe React.memo typing fixed in later version of Flow
return
MemoizedRootContextHOC
;
}
const
rootContextPropType
=
PropTypes
.
shape
({
detectUnsupervisedBackground
:
PropTypes
.
func
,
setNavStateInitialized
:
PropTypes
.
func
.
isRequired
,
onNavAction
:
PropTypes
.
func
.
isRequired
,
});
export
{
RootContext
,
withRootContext
,
rootContextPropType
};
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Sun, Dec 7, 4:24 PM (6 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5839551
Default Alt Text
root-context.js (1 KB)
Attached To
Mode
rCOMM Comm
Attached
Detach File
Event Timeline
Log In to Comment