Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make react-intl react 16 compatible #1201

Merged
merged 2 commits into from Oct 23, 2018

Conversation

ptomasroos
Copy link
Contributor

Closes #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

@ptomasroos
Copy link
Contributor Author

As mentioned by @ericf in this usage how to access the ref from the injectIntl component.
#811 (comment)

And thats how we use it through out our web app's as well.

@ptomasroos
Copy link
Contributor Author

Tests are failing because of current state in master i would say?

Jest: Coverage for functions (98.73%) does not meet global threshold (100%)

@redonkulus
Copy link
Member

Thanks for the PR. I'm fine merging if it doesn't break anyone.

As for the failing build, it looks like one of the tests are failing:

 FAIL  test/unit/react-intl-with-locales.js
  ● Test suite failed to run
    /home/travis/build/yahoo/react-intl/src/utils.js:2
    }});
    ^
    
    SyntaxError: Unexpected token }
      
      at new Script (vm.js:79:7)
      at Object.<anonymous> (src/inject.js:20:572)

It's not related to your PR, since master has the same problem, but do you mind seeing if it's an easy fix?

@ptomasroos
Copy link
Contributor Author

Sadly i can't reproduce this locally with same node version and can't really find the cause for this.
Seems to happen only on node 10 for some reason?

@ptomasroos
Copy link
Contributor Author

Any way to retrigger the test @redonkulus or continue to merge this anyway?

@redonkulus
Copy link
Member

redonkulus commented Oct 19, 2018

So the unit tests pass but the coverage is below 100%. master is 100% for all functions and those builds are passing. Can you get the inject file back up to 100% coverage?

@ptomasroos
Copy link
Contributor Author

TBH looking at the tests it look seriously solid. @redonkulus

@ptomasroos
Copy link
Contributor Author

But i will take a look if I can find something

@ptomasroos
Copy link
Contributor Author

Sorry @redonkulus I cant bring this to 100, its complaining about the ref callback assignment and I can't really find a way to test that "logic". Can you give me some insights?

@redonkulus
Copy link
Member

@ptomasroos A quick googling found this answer for testing the ref: https://stackoverflow.com/questions/48088489/react-jestjs-enzyme-how-to-test-for-reference-function

Another option you can do for coverage sake is just have jest ignore that line.

… invariant check where its implicitly covering the ref callback
@ptomasroos
Copy link
Contributor Author

Thanks for the patience @redonkulus.
I gave it a try through several examples out on the web, yours as well. But couldn't make it to get covered.

Hence I added a ignore line instead since I already feel this is covered through the existing lines which check the ref assignment through the invariant checks.

Would be great if we could merge and release this in order to avoid splitting the community into branches and forks as currently 16.6 users need to use https://www.npmjs.com/package/@freedombase/react-intl

Copy link
Member

@redonkulus redonkulus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing the work here!

@redonkulus redonkulus merged commit 1c5afd2 into formatjs:master Oct 23, 2018
redonkulus pushed a commit that referenced this pull request Oct 23, 2018
Commits:
- Make react-intl react 16 compatible (#1201)  1c5afd2
@redonkulus
Copy link
Member

published in v2.7.2

spyl94 pushed a commit to cap-collectif/react-intl that referenced this pull request Nov 22, 2018
Commits:
- Make react-intl react 16 compatible (formatjs#1201)  1c5afd2
spyl94 pushed a commit to cap-collectif/react-intl that referenced this pull request Nov 22, 2018
Commits:
- Make react-intl react 16 compatible (formatjs#1201)  1c5afd2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants