React package (#105)
* init new react package project * setup react package * Fix config for build * update package * Fix build * update package * fix package.json * refactor and cleanup * bumb beta version * fix regex * bump version * Add hashing * Add tests * bump version * Add peer dependecies * Add docs * Add readme link
This commit is contained in:
31
packages/lucide-react/src/createReactComponent.js
Normal file
31
packages/lucide-react/src/createReactComponent.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import { forwardRef, createElement } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
export default (iconName, [tag, attrs, children]) => {
|
||||
const Component = forwardRef(
|
||||
({ color = 'currentColor', size = 24, strokeWidth = 2, ...rest }, ref) =>
|
||||
createElement(
|
||||
tag,
|
||||
{
|
||||
ref,
|
||||
...attrs,
|
||||
width: size,
|
||||
height: size,
|
||||
color,
|
||||
strokeWidth,
|
||||
...rest,
|
||||
},
|
||||
children.map(([childTag, childAttrs]) => createElement(childTag, childAttrs)),
|
||||
),
|
||||
);
|
||||
|
||||
Component.propTypes = {
|
||||
color: PropTypes.string,
|
||||
size: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||||
};
|
||||
|
||||
Component.displayName = `${iconName}`;
|
||||
|
||||
return Component;
|
||||
};
|
||||
Reference in New Issue
Block a user