UNPKG

@shopify/flash-list

Version:

FlashList is a more performant FlatList replacement

27 lines 847 B
import React from "react"; /** * Helper function to handle both React components and React elements. * This utility ensures proper rendering of components whether they are passed as * component types or pre-rendered elements. * * @param component - Can be a React component type, React element, null, or undefined * @returns A valid React element if the input is valid, null otherwise * * @example * // With a component type * getValidComponent(MyComponent) * * @example * // With a pre-rendered element * getValidComponent(<MyComponent />) */ export const getValidComponent = (component) => { if (React.isValidElement(component)) { return component; } else if (typeof component === "function") { return React.createElement(component); } return null; }; //# sourceMappingURL=componentUtils.js.map