Skip to content

Commit

Permalink
Refactor: redefine name as an optional type
Browse files Browse the repository at this point in the history
This is the TypeScript Way
  • Loading branch information
dgmstuart committed Apr 23, 2024
1 parent 3b173be commit ec1e7a3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/components/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { ButtonClickHandler } from "../clickHandler";

const Card: React.FC<{
id: string;
name: string;
name?: string;
url: string;
wordList: string[];
videoListUrl?: string;
Expand Down
9 changes: 2 additions & 7 deletions src/components/DynamicCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@ import flattenWordList from "../lib/flattenWordList";
import type { KeyedConfig } from "../loaders/configLoaders";

const DynamicCard: React.FC = () => {
const {
id,
name = "",
url,
wordList,
videoListUrl,
} = useLoaderData() as KeyedConfig;
const { id, name, url, wordList, videoListUrl } =
useLoaderData() as KeyedConfig;

if (wordList.length > 0) {
// Card saves the word list to the session, so don't render a card if the
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/ContentLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { Config } from "../data/config";

const ContentLayout: React.FC = () => {
const { t } = useTranslation();
const { name = "", videoListUrl } = useLoaderData() as Config;
const { name, videoListUrl } = useLoaderData() as Config;

const headerContent = (
<>
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/MainLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Footer from "../components/Footer";
import LanguagePicker from "../components/LanguagePicker";

const MainLayout: React.FC<{
name: string;
name?: string;
headerContent: ReactNode;
body: ReactNode;
footerClass?: string;
Expand Down

0 comments on commit ec1e7a3

Please sign in to comment.