Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@react-facet/deferred-mount
Advanced tools
React Facet is a state management for performant game UIs. For more information on how to use this package check the official documentation available at https://react-facet.mojang.com/.
This package allows you to defer the mounting of a component to the next frame. By wrapping components on a big list you can keep the frame time low while everything is mounted.
When the DeferredMountProvider
is used, it requires that there is at least one descendent as a DeferredMount
or DeferredMountWithCallback
, otherwise it will wait forever as deferring
.
In the example below it will mount:
First
First
and Second
First
, Second
and Third
The useIsDeferring
hook allows to check what is the status of the deferred mounting (by returning a Facet) so we can, for example, show a spinner.
const SampleComponent = () => {
const isDeferringFacet = useIsDeferring()
return (
<>
<fast-text text={useFacetMap((isDeferring) => (isDeferring ? 'deferring' : 'done'), [], [isDeferringFacet])} />
<DeferredMount>
<div>First</div>
</DeferredMount>
<DeferredMount>
<div>Second</div>
</DeferredMount>
<DeferredMount>
<div>Third</div>
</DeferredMount>
</>
)
}
render(
<DeferredMountProvider frameTimeBudget={16}>
<SampleComponent />
</DeferredMountProvider>,
document.getElementById('root'),
)
The frameTimeBudget
prop allows the tweaking of how much time the library has available to do work on a given frame (by default it targets 60fps).
Some components may need to wait some time before they can be considered fully rendered (for example if they are fetching data). For these cases you should use DeferredMountWithCallback
with the useNotifyMountComplete
hook.
const DelayedComponent = () => {
const notifyMountComplete = useNotifyMountComplete()
const [data, setData] = useState()
useEffect(() => {
fetch('mock-api').then((data) => {
setData(data)
notifyMountComplete()
})
}, [notifyMountComplete])
return <div>{data}</div>
}
render(
<DeferredMountProvider>
<DeferredMountWithCallback>
<DelayedComponent />
</DeferredMountWithCallback>
</DeferredMountProvider>,
document.getElementById('root'),
)
FAQs
Unknown package
We found that @react-facet/deferred-mount demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.