-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(component): pass createElement
and Fragment
components
#26
Conversation
packages/react-recommendations/src/__tests__/RelatedProducts.tsx
Outdated
Show resolved
Hide resolved
packages/react-recommendations/src/__tests__/RelatedProducts.tsx
Outdated
Show resolved
Hide resolved
packages/react-recommendations/src/__tests__/RelatedProducts.tsx
Outdated
Show resolved
Hide resolved
|
||
import { ChildrenProps } from './types'; | ||
import { cx } from './utils'; | ||
|
||
export function DefaultChildren<TObject>(props: ChildrenProps<TObject>) { | ||
if (props.recommendations.length === 0) { | ||
return <props.Fallback />; | ||
return <props.Fallback createElement={createElement} Fragment={Fragment} />; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to pass createElement
and Fragment
in the FBT
and RP
components directly, otherwise they're not bound to these renderer props anywhere else than in our DefaultChildren
component.
The same applies with Header
and View
.
Wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! Is that what you had in mind? algolia/ui-components@fac42ac
Summary
Pass
createElement
andFragment
to the components returning aJSX.Element
which ease the user-land code when using vanilla JavaScript.JavaScript Example