diff --git a/src/index.tsx b/src/index.tsx index d8c161d..53c1345 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,2 +1,2 @@ export * from "./lib/shapes"; -export { default as shapes, shapeTypes } from "./shapes"; +export { default as shapes, shapeTypes, getRandomShape } from "./shapes"; diff --git a/src/lib/iconBase.tsx b/src/lib/iconBase.tsx index 5002b48..7446d3c 100644 --- a/src/lib/iconBase.tsx +++ b/src/lib/iconBase.tsx @@ -7,9 +7,8 @@ import React, { import NoiseMask from "./noiseMask"; // icon base props -export interface ShapeProps - extends RefAttributes, - Partial> { +type svgProps = RefAttributes & Partial>; +export interface ShapeProps extends svgProps{ size?: number; noise?: boolean; } diff --git a/src/lib/shapes.tsx b/src/lib/shapes.tsx index d6498df..6adcc5d 100644 --- a/src/lib/shapes.tsx +++ b/src/lib/shapes.tsx @@ -20,21 +20,20 @@ const Coolshape: ForwardRefExoticComponent = forwardRef( (options, ref) => { const { type, index, random, ...rest } = options; - let initialShape = null; - if (index !== undefined && type) { - initialShape = shapes[type][index]; + if (index !== undefined && type && !random) { + const Shape = shapes[type][index]; + return } - const [Shape, setShape] = useState(initialShape); + + const [RandomShape, setRandomShape] = useState(null); useEffect(() => { - if (random || !type || index === undefined) { const shape = getRandomShape({ type }) as ShapeType; - setShape(shape); - } + setRandomShape(shape); }, []); - if (!Shape) { - return null; + if (!RandomShape) { + return null; } - return ; + return ; } ); Coolshape.displayName = "Coolshape";