From da564f11e12cf8e92ca8532a0d36db1aaf1dc241 Mon Sep 17 00:00:00 2001 From: Viktor Ivarsson Date: Tue, 10 Apr 2018 13:25:04 +0200 Subject: [PATCH] fix(innerRef): allow ref as object (#409) * fix(innerRef): allow ref as object React 16.3 comes with a createRef API where you can add ref as an object * fix(test): update snapshots --- .all-contributorsrc | 9 +++++++++ README.md | 4 ++-- src/__tests__/__snapshots__/typescript.js.snap | 4 ++-- src/create-glamorous.js | 2 +- typings/glamorous-component.d.ts | 2 +- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 43aea70b..44b7ec56 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -596,6 +596,15 @@ "code", "test" ] + }, + { + "login": "viktorivarsson", + "name": "Viktor Ivarsson", + "avatar_url": "https://avatars1.githubusercontent.com/u/7829175?v=4", + "profile": "https://github.com/viktorivarsson", + "contributions": [ + "code" + ] } ] } diff --git a/README.md b/README.md index 77f35ebc..636be07d 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ [![downloads][downloads-badge]][npmcharts] [![MIT License][license-badge]][license] -[![All Contributors](https://img.shields.io/badge/all_contributors-62-orange.svg?style=flat-square)](#contributors) +[![All Contributors](https://img.shields.io/badge/all_contributors-63-orange.svg?style=flat-square)](#contributors) [![PRs Welcome][prs-badge]][prs] [![Chat][chat-badge]][chat] [![Code of Conduct][coc-badge]][coc] @@ -173,7 +173,7 @@ Thanks goes to these people ([emoji key][emojis]): | [
Lufty Wiranda](http://instagram.com/luftywiranda13)
[πŸ’»](https://github.com/paypal/glamorous/commits?author=luftywiranda13 "Code") | [
Ansuman Shah](https://github.com/ansumanshah)
[πŸ’»](https://github.com/paypal/glamorous/commits?author=ansumanshah "Code") [πŸ“–](https://github.com/paypal/glamorous/commits?author=ansumanshah "Documentation") | [
Travis LaDuke](http://-)
[πŸ’‘](#example-laduke "Examples") | [
AydΔ±n Γ‡ağrΔ± Dumlu](https://github.com/acgrdumlu)
[πŸ›](https://github.com/paypal/glamorous/issues?q=author%3Aacgrdumlu "Bug reports") [πŸ’»](https://github.com/paypal/glamorous/commits?author=acgrdumlu "Code") | [
Maja Wichrowska](https://github.com/majapw)
[πŸ›](https://github.com/paypal/glamorous/issues?q=author%3Amajapw "Bug reports") | [
Tom Liu](https://github.com/gt3240)
[πŸ“–](https://github.com/paypal/glamorous/commits?author=gt3240 "Documentation") | [
Siddharth Kshetrapal](https://github.com/siddharthkp)
[⚠️](https://github.com/paypal/glamorous/commits?author=siddharthkp "Tests") [πŸ”§](#tool-siddharthkp "Tools") | | [
WillowHQ](https://github.com/WillowHQ)
[πŸ“–](https://github.com/paypal/glamorous/commits?author=WillowHQ "Documentation") | [
Mohammad Rajabifard](https://tarino.ir)
[πŸ›](https://github.com/paypal/glamorous/issues?q=author%3Amorajabi "Bug reports") [πŸ“–](https://github.com/paypal/glamorous/commits?author=morajabi "Documentation") | [
Omar Albacha](https://github.com/Oalbacha)
[πŸ’»](https://github.com/paypal/glamorous/commits?author=Oalbacha "Code") [πŸ“–](https://github.com/paypal/glamorous/commits?author=Oalbacha "Documentation") | [
tdeschryver](https://github.com/tdeschryver)
[πŸ’»](https://github.com/paypal/glamorous/commits?author=tdeschryver "Code") [⚠️](https://github.com/paypal/glamorous/commits?author=tdeschryver "Tests") | [
Dylan Mozlowski](https://github.com/DylanMoz)
[πŸ’»](https://github.com/paypal/glamorous/commits?author=DylanMoz "Code") | [
andretshurotshka](https://github.com/goodmind)
[πŸ’»](https://github.com/paypal/glamorous/commits?author=goodmind "Code") [⚠️](https://github.com/paypal/glamorous/commits?author=goodmind "Tests") | [
Danila](https://github.com/O4epegb)
[⚠️](https://github.com/paypal/glamorous/commits?author=O4epegb "Tests") | | [
Junyoung Clare Jang](http://ailrun.github.io/)
[πŸ’»](https://github.com/paypal/glamorous/commits?author=Ailrun "Code") [⚠️](https://github.com/paypal/glamorous/commits?author=Ailrun "Tests") | [
BjΓΆrn Ricks](https://twitter.com/bjoernricks)
[πŸ›](https://github.com/paypal/glamorous/issues?q=author%3Abjoernricks "Bug reports") [πŸ’»](https://github.com/paypal/glamorous/commits?author=bjoernricks "Code") [πŸ“–](https://github.com/paypal/glamorous/commits?author=bjoernricks "Documentation") [⚠️](https://github.com/paypal/glamorous/commits?author=bjoernricks "Tests") | [
Tyler Deitz](http://tylerdeitz.com)
[πŸ’»](https://github.com/paypal/glamorous/commits?author=tvler "Code") | [
Shovan Chatterjee](https://twitter.com/shovan_ch)
[πŸ“–](https://github.com/paypal/glamorous/commits?author=shovanch "Documentation") | [
johnjessewood](https://github.com/johnjesse)
[πŸ’»](https://github.com/paypal/glamorous/commits?author=johnjesse "Code") | [
Daniel](https://www.danielberndt.net)
[πŸ’»](https://github.com/paypal/glamorous/commits?author=danielberndt "Code") [⚠️](https://github.com/paypal/glamorous/commits?author=danielberndt "Tests") | [
Ken Powers](https://knpw.rs)
[πŸ€”](#ideas-knpwrs "Ideas, Planning, & Feedback") [πŸ’‘](#example-knpwrs "Examples") | -| [
John Grishin](http://johngrish.in)
[πŸ›](https://github.com/paypal/glamorous/issues?q=author%3Aexah "Bug reports") [πŸ’»](https://github.com/paypal/glamorous/commits?author=exah "Code") [⚠️](https://github.com/paypal/glamorous/commits?author=exah "Tests") | [
Mordy Tikotzky](https://github.com/tikotzky)
[πŸ›](https://github.com/paypal/glamorous/issues?q=author%3Atikotzky "Bug reports") [πŸ’»](https://github.com/paypal/glamorous/commits?author=tikotzky "Code") | [
Alasdair McLeay](https://github.com/penx)
[πŸ’‘](#example-penx "Examples") | [
Ardamis Yeshak](https://github.com/zabute)
[πŸ”§](#tool-zabute "Tools") | [
Matthew Armstrong](https://github.com/raingerber)
[⚠️](https://github.com/paypal/glamorous/commits?author=raingerber "Tests") | [
Wu Haotian](https://github.com/whtsky)
[πŸ’»](https://github.com/paypal/glamorous/commits?author=whtsky "Code") [⚠️](https://github.com/paypal/glamorous/commits?author=whtsky "Tests") | +| [
John Grishin](http://johngrish.in)
[πŸ›](https://github.com/paypal/glamorous/issues?q=author%3Aexah "Bug reports") [πŸ’»](https://github.com/paypal/glamorous/commits?author=exah "Code") [⚠️](https://github.com/paypal/glamorous/commits?author=exah "Tests") | [
Mordy Tikotzky](https://github.com/tikotzky)
[πŸ›](https://github.com/paypal/glamorous/issues?q=author%3Atikotzky "Bug reports") [πŸ’»](https://github.com/paypal/glamorous/commits?author=tikotzky "Code") | [
Alasdair McLeay](https://github.com/penx)
[πŸ’‘](#example-penx "Examples") | [
Ardamis Yeshak](https://github.com/zabute)
[πŸ”§](#tool-zabute "Tools") | [
Matthew Armstrong](https://github.com/raingerber)
[⚠️](https://github.com/paypal/glamorous/commits?author=raingerber "Tests") | [
Wu Haotian](https://github.com/whtsky)
[πŸ’»](https://github.com/paypal/glamorous/commits?author=whtsky "Code") [⚠️](https://github.com/paypal/glamorous/commits?author=whtsky "Tests") | [
Viktor Ivarsson](https://github.com/viktorivarsson)
[πŸ’»](https://github.com/paypal/glamorous/commits?author=viktorivarsson "Code") | diff --git a/src/__tests__/__snapshots__/typescript.js.snap b/src/__tests__/__snapshots__/typescript.js.snap index a36a1666..9d1c14ec 100644 --- a/src/__tests__/__snapshots__/typescript.js.snap +++ b/src/__tests__/__snapshots__/typescript.js.snap @@ -105,13 +105,13 @@ test/should-fail.test.tsx(272,18): error TS2345: Argument of type '{ textAlign: test/should-fail.test.tsx(289,35): error TS2322: Type '{ display: \\"blocks\\"; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes'. Types of property 'display' are incompatible. - Type '\\"blocks\\"' is not assignable to type '\\"none\\" | \\"ruby\\" | \\"table\\" | \\"inline\\" | \\"grid\\" | \\"initial\\" | \\"inherit\\" | \\"unset\\" | \\"block\\" | \\"run-...'. + Type '\\"blocks\\"' is not assignable to type '\\"none\\" | \\"ruby\\" | \\"table\\" | \\"inherit\\" | \\"initial\\" | \\"unset\\" | \\"contents\\" | \\"block\\" | \\"inline\\" | \\"...'. test/should-fail.test.tsx(290,38): error TS2559: Type '{ display: string; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes & object & CSS...'. Type '{ display: \\"blocks\\"; }' is not assignable to type 'Readonly & object & CSSProperties & ExtraGlamorousProps>'. Types of property 'display' are incompatible. - Type '\\"blocks\\"' is not assignable to type '\\"none\\" | \\"ruby\\" | \\"table\\" | \\"inline\\" | \\"grid\\" | \\"initial\\" | \\"inherit\\" | \\"unset\\" | \\"block\\" | \\"run-...'. + Type '\\"blocks\\"' is not assignable to type '\\"none\\" | \\"ruby\\" | \\"table\\" | \\"inherit\\" | \\"initial\\" | \\"unset\\" | \\"contents\\" | \\"block\\" | \\"inline\\" | \\"...'. test/should-fail.test.tsx(294,32): error TS2559: Type '{ display: string; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes & object & Ext...'. test/should-fail.test.tsx(295,36): error TS2559: Type '{ display: string; }' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes & object & Ext...'. " diff --git a/src/create-glamorous.js b/src/create-glamorous.js index 4205bc68..6a57385b 100644 --- a/src/create-glamorous.js +++ b/src/create-glamorous.js @@ -100,7 +100,7 @@ function createGlamorous(splitProps) { // returning an object with a toString method that gives the className className: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), cssOverrides: PropTypes.object, - innerRef: PropTypes.func, + innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), glam: PropTypes.object, } diff --git a/typings/glamorous-component.d.ts b/typings/glamorous-component.d.ts index c15cb0e4..a9598fdf 100644 --- a/typings/glamorous-component.d.ts +++ b/typings/glamorous-component.d.ts @@ -14,7 +14,7 @@ export interface ExtraGlamorousProps { /** * Called with the inner element's reference */ - innerRef?: (instance: any) => void + innerRef?: object | ((instance: any) => void) className?: string /**