Formik: Warnings on Draft.js/Immutable.js when the latest version of formik is used (iterable.length has been deprecated)

Created on 1 Jun 2018  路  9Comments  路  Source: formium/formik

Describe the bug
When you use the latest version of formik (0.11.11, in my case) and draftjs, you get hundreds warnings throwed by immutable, that looks like this:

iterable.length has been deprecated, use iterable.size or iterable.count(). This warning will become a silent error in a future version.

For every action you do on the editor, you get 16 of this warning (this includes focusing, unfocusing, typing, etc), so for example, if you focus the editor, type this is a sentence, and focus away, you will get 352 warnings on your console (and this is a short sentence, imagine with longer ones). This quickly pollutes the console log, and on slower devices, it hurts the performance of the editor (everything feels sluggish), because of the quantity of those warnings.

To Reproduce

  1. Open the official draftjs example
  2. Update formik to the latest version (currently 0.11.11)
  3. Focus the editor
    3.1 Type something on the editor (optional)
  4. Check the console

Expected behavior
No warnings throwed by Draftjs when using formik

Suggested solution(s)
I did some digging, and apparently, the line causing the warning is the following https://github.com/jaredpalmer/formik/blob/3520bada9675985a9d024894f61eca3d82df63b6/src/formik.tsx#L628
It comes from lodash.isequal, and looking at the method it takes me to this line, which contains a call to .length. Lodash is mistakenly thinking that immutable creates an array (it kind of simulates that behaviour, but technicaly it is not), and try to access .length on it, which is being deprecated (on the latest version of immutable, .length returns undefined, but draftjs uses version ~3.7.4, which still has the .length value).

Apparently, the issue started on version 0.11.0-rc.1, and it doesn't happen on 0.11.0-beta.1 (or any version before that). This does not happen too on 1.0.0-beta.2, so maybe looking there can bring some clues as to how to fix this on ^0.11.0


  • Formik Version: 0.11.0-beta.1 and beyond
  • React Version: 15.5.3
  • TypeScript Version: n/a
  • CodeSandbox Link: https://codesandbox.io/s/3q7x9y6ym1
  • OS: Windows 10
  • Node Version: 10
  • Package Manager and Version: yarn 1.7.0
stale

All 9 comments

@GabrielDuarteM does this happen on the beta? formik uses react-fast-compare there rather than lodash.isequal

@slightlytyler It started happening on 0.11.0-rc.1 (it was fine on 0.11.0-beta.1) and does not happen on 1.0.0-beta.2.

One weird thing happened, I tried when I was creating this bug to make an example using react-fast-compare to compare two instances of an immutable list, and it resulted in fewer warnings, but still had warnings (compared to three warnings when using lodash.isequal). Now I tried again, and no warnings were thrown when using react-fast-compare, not sure why, maybe I did something weird. You can see the comparison on this sandbox.

Would you mind if I make a PR trying to change the dependency from lodash.isequal to react-fast-compare?

@GabrielDuarteM that's already done -- this change is in the current beta. You just need to upgrade

@slightlytyler If I were using formik on I project I owe, I wouldn't mind it at all, but it's a project of my company, so I don't think it would be well received to install a beta version, as it is not a stable version, and could change anytime (as well as contain bugs).

Wouldn't it be possible to release a fix for this on this current major version (0.11)? As I said, I can help with the PR, if needed 馃憤

I expect to cut 1.0-rc鈥檚 in the next week or so

Pretty sure the 1.0 beta is more stable than 0.11 at this point. Adding the "stable" adjective to any pre-1.0 software sounds like an oxymoron to me lol

Also bumping that package would require a new minor anyways I think

If that's the case, and a final version is probably coming soon, then I think it should not be a problem to install this beta...

Anyway, not sure if I should close this now, or only when the 1.0 version is released, so feel free to close it if you think its better this way 馃憤

Hola! So here's the deal, between open source and my day job and life and what not, I have a lot to manage, so I use a GitHub bot to automate a few things here and there. This particular GitHub bot is going to mark this as stale because it has not had recent activity for a while. It will be closed if no further activity occurs in a few days. Do not take this personally--seriously--this is a completely automated action. If this is a mistake, just make a comment, DM me, send a carrier pidgeon, or a smoke signal.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

outaTiME picture outaTiME  路  3Comments

pmonty picture pmonty  路  3Comments

jeffbski picture jeffbski  路  3Comments

Jucesr picture Jucesr  路  3Comments

sibelius picture sibelius  路  3Comments