Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@dhis2/app-runtime-adapter-d2
Advanced tools
Support [`d2`](https://github.com/dhis2/d2) and [`d2-ui`](https://github.com/dhis2/d2-ui) components in [DHIS2 Platform](https://platform.dhis2.nu) applications
Support d2
and d2-ui
components in DHIS2 Platform applications
Ths library has two peer dependencies:
There are two entrypoints to support initialization and access to the d2
singleton from within an application.
useD2
, a React Hookimport React, { useState } from 'react'
import { useD2 } from '@dhis2/app-runtime-adapter-d2'
import { getUserSettings } from 'd2'
const d2Config = {
schemas: ['dataElement', 'program', 'userGroup'],
}
const MyApp = () => {
const [userSettings, setUserSettings] = useState(null)
const onInitialized = d2 => {
getUserSettings().then(setUserSettings)
/* ... do other things with d2 ... */
}
const { d2, d2Error } = useD2({ d2Config, onInitialized })
/* ... optionally render error or loading state ... */
if (d2 && !d2Error && userSettings) {
/* ... render the application ... */
}
}
export default MyApp
D2Shim
, a React Component that wraps the useD2
hook. It accepts a single child functionimport React, { useState } from 'react'
import { useD2 } from '@dhis2/app-runtime-adapter-d2'
import { getUserSettings } from 'd2'
import { ScreenCover, CircularLoader } from '@dhis2/ui-core'
import Root from './components/Root' // This is the business logic of the application
const d2Config = {
schemas: ['dataElement', 'program', 'userGroup'],
}
const onD2Initialized = async d2 => {
const userSettings = await getUserSettings()
/* do something with userSettings or d2 - spawn Redux initialization actions, for instance */
}
const MyApp = () => (
<D2Shim d2Config={d2Config} onInitialized={onD2Initialized}>
{({ d2, d2Error }) => (
<>
{d2Error && (
<div
style={{
display: 'flex',
height: '100%',
width: '100%',
alignItems: 'center',
justifyContent: 'center',
}}
>
{`D2 initialization error: ${d2Error}`}
</div>
)}
{!d2 && !d2Error && (
<ScreenCover>
<CircularLoader />
</ScreenCover>
)}
{d2 && <Root d2={d2} store={store} />}
</>
)}
</D2Shim>
)
export default MyApp
Both accept three options:
d2Config
- an object passed to the init
function when initializing d2
onInitialized
- a callback function executed when d2
has been initialized. It will be awaited, so returning a promise will delay resolution of the d2
return value.i18nRoot
- an optional string that indicates the app's directory containing "legacy" i18n files, e.g., i18n_module_en.properties. In data-visualier, for example, the string would be "i18n_old". When this string is set, the properties file of the current language will be loaded.The same two entrypoints can be used multiple places within an application to reference the d2
singleton. Once d2
has been initialized it will not be re-initialized, so you can safely call useD2
or render D2Shim
without any arguments further down the VDom tree after rendering D2Shim
with initialization parameters at the application entrypoint.
The issue tracker can be found in DHIS2 JIRA under the LIBS project.
Deep links:
FAQs
Support [`d2`](https://github.com/dhis2/d2) and [`d2-ui`](https://github.com/dhis2/d2-ui) components in [DHIS2 Platform](https://platform.dhis2.nu) applications
The npm package @dhis2/app-runtime-adapter-d2 receives a total of 311 weekly downloads. As such, @dhis2/app-runtime-adapter-d2 popularity was classified as not popular.
We found that @dhis2/app-runtime-adapter-d2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 14 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.