Skip to content

Conversation

@maiieul
Copy link
Contributor

@maiieul maiieul commented Nov 1, 2025

fix Render component not recognizing user defined props

e.g.

In

import { component$, PropsOf, Slot, useStyles$ } from "@qwik.dev/core";
import { AsChildTypes } from "@qds.dev/tools/vite";
import { Render } from "@qds.dev/ui";

import buttonStyles from "./button.css?inline";
import { SharedButtonSizes, SharedButtonVariants } from "./shared";

export type ButtonVariant =
  | SharedButtonVariants
  | "link"
  | "alt-link"
  | "danger-outline"
  | "danger-ghost";

export type ButtonProps = PropsOf<"button"> &
  AsChildTypes & {
    variant?: ButtonVariant;
    size?: SharedButtonSizes;
    unstyled?: boolean;
  };

export const Button = component$<ButtonProps>(
  ({ variant = "primary", size = "md", unstyled = false, ...props }) => {
    useStyles$(buttonStyles);
    return (
      <Render
        {...props}
        fallback="button"
        class={[!unstyled && "btn", props.class]}
        unstyled={unstyled}
        variant={variant}
        size={size}
      >
        <Slot />
      </Render>
    );
  },
);

unstyled, variant and size will throw even though they are valid.

The new implementation is a bit more loose on the extra props but can be made stricter again using

<Render<{ ... }>
  fallback=...
</Render>

Note

Updates Render component typings to generically accept user-defined props while retaining fallback element typings and bind:* filtering.

  • Components
    • Render (libs/components/src/render/render.tsx):
      • Introduces generic RenderProps<P, T> to merge user-defined props P with fallback element props T.
      • Updates Render signature to use <P, T> generics, enabling custom prop passthrough.
      • Removes Record<${string}$, unknown> from internal props, tightening unintended prop patterns.
      • Preserves existing behavior: fallback element/component resolution and bind:* attribute filtering.

Written by Cursor Bugbot for commit 8022085. This will update automatically on new commits. Configure here.

@changeset-bot
Copy link

changeset-bot bot commented Nov 1, 2025

⚠️ No Changeset found

Latest commit: 8022085

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

cursor[bot]

This comment was marked as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant