Skip to content

Commit

Permalink
Fixed issue that happens on network calls errors out
Browse files Browse the repository at this point in the history
  • Loading branch information
aliofye committed Jan 17, 2025
1 parent 81ba184 commit 77bb741
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ExampleCodeBlock from '@/web/components/ExampleCodeBlock';

interface ExampleProps {
message: string;
message: string | null;
}

const Example: React.FC<ExampleProps> = ({ message }) => {
Expand Down
11 changes: 8 additions & 3 deletions packages/web/app/routes/examples.server/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ import Example from './components/Example';
import { getMessage } from './loaders';

export const clientLoader = async () => {
const data = await getMessage();
return data;
try {
const { text } = await getMessage();
return text;
} catch (err) {
console.error('Error loading data:', err);
return null;
}
};

const ServerExample = ({ loaderData }: Route.ComponentProps) => {
const { text } = loaderData;
const text = loaderData;

return (
<div className="content">
Expand Down

0 comments on commit 77bb741

Please sign in to comment.