20CAKE20.JS
06-components

Components

23

06-components/07-dynamic.tsx

Dynamic

Example

Official Cake20 View example for dynamic.

export const data = {
  view: "profile" as "profile" | "settings",
};

const views = {
  profile: () => <ProfilePanel />,
  settings: () => <SettingsPanel />,
};

export default () => {
  const Current = views[data.view];

  return (
    <main class="p-8">
      <Current />
    </main>
  );
};