mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-19 14:19:21 +01:00
Add lucide-react-native package (#687)
* 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>
This commit is contained in:
41
packages/lucide-react-native/src/createReactComponent.js
Normal file
41
packages/lucide-react-native/src/createReactComponent.js
Normal file
@@ -0,0 +1,41 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user