update helloworld template for component,

This commit is contained in:
louiscklaw
2025-05-12 11:34:06 +08:00
parent af446aed59
commit 1a77c3a5e8

View File

@@ -6,6 +6,9 @@ import ListItemIcon from '@mui/material/ListItemIcon';
import { Box } from '@mui/system';
import { Trash as TrashIcon } from '@phosphor-icons/react/dist/ssr/Trash';
import { logger } from '@/lib/default-logger';
import { toast } from '@/components/core/toaster';
interface PropsHelloworld {
message: string;
}
@@ -33,11 +36,21 @@ function InnerComponent(): React.JSX.Element {
// RULES: sample of main component
function MainComponent(): React.JSX.Element {
const [state, setState] = React.useState<string>('');
const [loading, setLoading] = React.useState(true);
const [showError, setShowError] = React.useState<boolean>(false);
React.useEffect(() => {
setState(funcHelloworld('hello'));
try {
setState(funcHelloworld('hello'));
} catch (error) {
setShowError(true);
}
setLoading(false);
}, []);
if (loading) return <>Loading</>;
if (showError) return <>Error</>;
// you should obey react/jsx-no-useless-fragment
return (
<Box>