From d92bef31a5845c1e44f87888b1c3c1c528323b6c Mon Sep 17 00:00:00 2001 From: Ain Sal Date: Tue, 19 Feb 2019 06:56:41 +0300 Subject: [PATCH] Support factoryProps --- CHANGELOG.md | 4 ++++ package.json | 2 +- src/styled.js | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 488b0e8..15eb114 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.0.9 + +- Support passing default props to the factory. + # 0.0.8 - Support dynamic props in `attrs()`. By default `attrs()` only overwrites the `defaultProps` of the component, now when you pass it a function it will allow for computed props. diff --git a/package.json b/package.json index 635fa8f..8ee145f 100755 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "license": "MIT", "name": "shakl", "description": "A utility to create styled components in React Native.", - "version": "0.0.8", + "version": "0.0.9", "main": "lib/index.js", "react-native": "lib/rn.js", "repository": { diff --git a/src/styled.js b/src/styled.js index 495ff3b..addc82b 100644 --- a/src/styled.js +++ b/src/styled.js @@ -4,7 +4,7 @@ import flatten from './flatten' import { ThemeProvider, withTheme } from './theme' -const styled = (Comp, { name, multi, ...opts } = {}) => (style) => { +const styled = (Comp, { name, multi, props: factoryProps, ...opts } = {}) => (style) => { const Styled = React.forwardRef(({ childRef, ...props }, ref) => { const { comp, child, childProps } = opts const { children } = props @@ -28,6 +28,7 @@ const styled = (Comp, { name, multi, ...opts } = {}) => (style) => { } const parentProps = { + ...factoryProps, ...attrs, ...props, ...styles,