diff --git a/cli/config/init.entrypoint.js b/cli/config/init.entrypoint.js index c8ed94cd..55970a28 100644 --- a/cli/config/init.entrypoint.js +++ b/cli/config/init.entrypoint.js @@ -1,4 +1,4 @@ -import { DataQuery } from '@dhis2/app-runtime' +import { useDataQuery } from '@dhis2/app-runtime' import i18n from '@dhis2/d2-i18n' import React from 'react' import classes from './App.module.css' @@ -9,27 +9,23 @@ const query = { }, } -const MyApp = () => ( -
- - {({ error, loading, data }) => { - if (error) { - return ERROR - } - if (loading) { - return ... - } - return ( - <> -

- {i18n.t('Hello {{name}}', { name: data.me.name })} -

-

{i18n.t('Welcome to DHIS2!')}

- - ) - }} -
-
-) +const MyApp = () => { + const { error, loading, data } = useDataQuery(query) + + if (error) { + return {i18n.t('ERROR')} + } + + if (loading) { + return {i18n.t('Loading...')} + } + + return ( +
+

{i18n.t('Hello {{name}}', { name: data?.me?.name })}

+

{i18n.t('Welcome to DHIS2!')}

+
+ ) +} export default MyApp