From 9fff97cbb11f880229c95043bd61b14f06c32aec Mon Sep 17 00:00:00 2001 From: Thomas Zemp Date: Mon, 22 Jul 2024 15:30:58 +0200 Subject: [PATCH] feat: update initial app code [LIBS-644] --- cli/config/init.entrypoint.js | 42 ++++++++++++++++------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/cli/config/init.entrypoint.js b/cli/config/init.entrypoint.js index c8ed94cdf..7cc3b0437 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