Skip to content

Commit 1c5afd2

Browse files
ptomasroosredonkulus
authored andcommitted
Make react-intl react 16 compatible (formatjs#1201)
Closes formatjs#1078 This is not a breaking change since the access of the ref is used when calling getWrappedInstance() In order to support React 16. We need to remove the legacy way of using ref's by setting a string. This is now marked as legacy. ``` We advise against it because string refs have some issues, are considered legacy, and are likely to be removed in one of the future releases. Note If you’re currently using this.refs.textInput to access refs, we recommend using either the callback pattern or the createRef API. ``` https://reactjs.org/docs/refs-and-the-dom.html#legacy-api-string-refs
1 parent 4bb6e27 commit 1c5afd2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/inject.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ export default function injectIntl(WrappedComponent, options = {}) {
4242
'`injectIntl()`'
4343
);
4444

45-
return this.refs.wrappedInstance;
45+
return this._wrappedInstance;
4646
}
4747

4848
render() {
4949
return (
5050
<WrappedComponent
5151
{...this.props}
5252
{...{[intlPropName]: this.context.intl}}
53-
ref={withRef ? 'wrappedInstance' : null}
53+
ref={withRef ? /* istanbul ignore next */ (ref => this._wrappedInstance = ref) : null}
5454
/>
5555
);
5656
}

0 commit comments

Comments
 (0)