Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F122590464
Hydrate.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Jul 20, 21:35
Size
856 B
Mime Type
text/x-java
Expires
Tue, Jul 22, 21:35 (2 d)
Engine
blob
Format
Raw Data
Handle
27509658
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
Hydrate.js
View Options
import
React
from
'react'
;
import
{
hydrate
}
from
'../core'
;
import
{
useQueryClient
}
from
'./QueryClientProvider'
;
export
function
useHydrate
(
state
,
options
)
{
var
queryClient
=
useQueryClient
();
var
optionsRef
=
React
.
useRef
(
options
);
optionsRef
.
current
=
options
;
// Running hydrate again with the same queries is safe,
// it wont overwrite or initialize existing queries,
// relying on useMemo here is only a performance optimization.
// hydrate can and should be run *during* render here for SSR to work properly
React
.
useMemo
(
function
()
{
if
(
state
)
{
hydrate
(
queryClient
,
state
,
optionsRef
.
current
);
}
},
[
queryClient
,
state
]);
}
export
var
Hydrate
=
function
Hydrate
(
_ref
)
{
var
children
=
_ref
.
children
,
options
=
_ref
.
options
,
state
=
_ref
.
state
;
useHydrate
(
state
,
options
);
return
children
;
};
Event Timeline
Log In to Comment