Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const Comp = (
{ as = type, ...props }: PropsWithAs,
ref: React.Ref
) => {
if (useHook) {
const [options, htmlProps] = splitProps(props, keys);
const { unstable_wrap, ...elementProps } = useHook(options, {
ref,
...htmlProps
});
// @ts-ignore
const asKeys = as.render ? as.render.__keys : as.__keys;
const asOptions = asKeys ? splitProps(props, asKeys)[0] : {};
const element = useCreateElement(as, { ...elementProps, ...asOptions });
if (unstable_wrap) {
return unstable_wrap(element);
}
return element;
}
return useCreateElement(as, props);
};
const Comp = (
{ as = type, ...props }: PropsWithAs,
ref: React.Ref
) => {
if (useHook) {
const [options, htmlProps] = splitProps(props, keys);
const { unstable_wrap, ...elementProps } = useHook(options, {
ref,
...htmlProps
});
// @ts-ignore
const asKeys = as.render ? as.render.__keys : as.__keys;
const asOptions = asKeys ? splitProps(props, asKeys)[0] : {};
const element = useCreateElement(as, { ...elementProps, ...asOptions });
if (unstable_wrap) {
return unstable_wrap(element);
}
return element;
}
return useCreateElement(as, props);
};