diff --git a/.eslintrc.js b/.eslintrc.js index 46a4bfffb2..487c2881d2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -70,6 +70,7 @@ const eslintrc = { 'import/no-cycle': 0, 'react/no-find-dom-node': 0, 'no-underscore-dangle': 0, + 'react/sort-comp': 0, // label-has-for has been deprecated // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md 'jsx-a11y/label-has-for': 0, diff --git a/CHANGELOG.en-US.md b/CHANGELOG.en-US.md index 055ed7cdd9..bbc54b9779 100644 --- a/CHANGELOG.en-US.md +++ b/CHANGELOG.en-US.md @@ -15,6 +15,12 @@ timeline: true --- +## 3.23.6 + +`2019-10-05` + +- 🐞 Fix Typography `ref` warning of React. [#19074](https://github.com/ant-design/ant-design/pull/19074) + ## 3.23.5 `2019-09-29` diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index a69b953059..9700f26f07 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -15,6 +15,12 @@ timeline: true --- +## 3.23.6 + +`2019-10-05` + +- 🐞 修复 Typography 提示获取不到 `ref` 的错误信息。[#19074](https://github.com/ant-design/ant-design/pull/19074) + ## 3.23.5 `2019-09-29` diff --git a/components/_util/ref.ts b/components/_util/ref.ts new file mode 100644 index 0000000000..6221eb1041 --- /dev/null +++ b/components/_util/ref.ts @@ -0,0 +1,17 @@ +import React from 'react'; + +export function fillRef(ref: React.Ref, node: T) { + if (typeof ref === 'function') { + ref(node); + } else if (typeof ref === 'object' && ref && 'current' in ref) { + (ref as any).current = node; + } +} + +export function composeRef(...refs: React.Ref[]): React.Ref { + return (node: T) => { + refs.forEach(ref => { + fillRef(ref, node); + }); + }; +} diff --git a/components/button/__tests__/index.test.js b/components/button/__tests__/index.test.js index a5ef8080c2..8e3b270777 100644 --- a/components/button/__tests__/index.test.js +++ b/components/button/__tests__/index.test.js @@ -206,6 +206,7 @@ describe('Button', () => { it('should merge text if children using variable', () => { const wrapper = mount( , ); diff --git a/components/collapse/__tests__/__snapshots__/demo.test.js.snap b/components/collapse/__tests__/__snapshots__/demo.test.js.snap index 31a5ebdd19..0938d15c57 100644 --- a/components/collapse/__tests__/__snapshots__/demo.test.js.snap +++ b/components/collapse/__tests__/__snapshots__/demo.test.js.snap @@ -638,7 +638,9 @@ exports[`renders ./components/collapse/demo/extra.md correctly 1`] = `
- Expand Icon Position: + + Expand Icon Position: +
diff --git a/components/collapse/demo/extra.md b/components/collapse/demo/extra.md index 0c79f8f413..770bc11588 100644 --- a/components/collapse/demo/extra.md +++ b/components/collapse/demo/extra.md @@ -68,7 +68,7 @@ class Demo extends React.Component {
- Expand Icon Position:{' '} + Expand Icon Position: