Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#67988 [react-sticky-el] Allow any host com…
Browse files Browse the repository at this point in the history
…ponent `*Cmp` props by @eps1lon

* [react-sticky-el] Allow any host component `*Cmp` props

`ReactHTML` will be removed soon.
It also needlessly restricts components to known HTML components when probably any host
component was meant.
This allows custom elements.

* Add test
  • Loading branch information
eps1lon authored Jan 10, 2024
1 parent bd172f1 commit c337f92
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions types/react-sticky-el/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ declare namespace Sticky {
*
* Defaults to 'div'.
*/
wrapperCmp?: keyof React.ReactHTML | React.ReactElement | undefined;
wrapperCmp?: keyof React.JSX.IntrinsicElements | React.ReactElement | undefined;

/**
* Anything that can be used by React.createElement. Used for holder
Expand All @@ -43,7 +43,7 @@ declare namespace Sticky {
*
* Defaults to 'div'.
*/
holderCmp?: keyof React.ReactHTML | React.ReactElement<HolderProps> | undefined;
holderCmp?: keyof React.JSX.IntrinsicElements | React.ReactElement<HolderProps> | undefined;

/**
* These props will be used to create `holderElement`.
Expand Down
10 changes: 10 additions & 0 deletions types/react-sticky-el/react-sticky-el-tests.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import * as React from "react";
import Sticky from "react-sticky-el";

declare module "react" {
namespace JSX {
interface IntrinsicElements {
"custom-element": unknown;
}
}
}

const StickyBasic = () => <Sticky />;
const StickyAllFeatures = () => (
<Sticky
Expand All @@ -21,3 +29,5 @@ const StickyAllFeatures = () => (
children="a child"
/>
);

<Sticky wrapperCmp="custom-element" />;

0 comments on commit c337f92

Please sign in to comment.