mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-16 22:27:43 +01:00
* Add `lucide-react-native` package Closes #394 * minor fixes build config * Add `lucide-react-native` package Closes #394 * make it work Co-authored-by: Eric Fennis <eric.fennis@gmail.com>
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
import { forwardRef, createElement } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import * as NativeSvg from 'react-native-svg';
|
|
import defaultAttributes from './defaultAttributes';
|
|
|
|
const createReactComponent = (iconName, iconNode) => {
|
|
const Component = forwardRef(
|
|
({ color = 'currentColor', size = 24, strokeWidth = 2, children, ...rest }, ref) =>
|
|
createElement(
|
|
NativeSvg.Svg,
|
|
{
|
|
ref,
|
|
...defaultAttributes,
|
|
width: size,
|
|
height: size,
|
|
stroke: color,
|
|
strokeWidth,
|
|
...rest,
|
|
},
|
|
[
|
|
...iconNode.map(([tag, attrs]) => {
|
|
const uppercasedTag = tag.charAt(0).toUpperCase() + tag.slice(1);
|
|
return createElement(NativeSvg[uppercasedTag], attrs);
|
|
}),
|
|
...(children || []),
|
|
],
|
|
),
|
|
);
|
|
|
|
Component.propTypes = {
|
|
color: PropTypes.string,
|
|
size: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
strokeWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
};
|
|
|
|
Component.displayName = `${iconName}`;
|
|
|
|
return Component;
|
|
};
|
|
|
|
export default createReactComponent;
|