-
Notifications
You must be signed in to change notification settings - Fork 49k
Description
** Reporting a bug
The problem I'm having is in the interplay of several packages but I feel that the only package actually doing something wrong here is react.
Versions:
- react 16.2.0 (also happened with 15.something)
- node.js 7.9 (electron 1.7.10)
- windows 10
** Current behavior
I get the error message from here https://reactjs.org/warnings/refs-must-have-owner.html although none of the three explanations is true.
Actually react is loaded twice but it's the same version and there is little I can do to prevent it.
What happens, as far as I can understand is this:
my application imports react from in two ways
- application -> react
- application -> node_modules/myapi -> react
both get the same react module from the same path.
However, the myapi module is installed via yarn link.
Now on case-insensitive filesystems, yarn link can cause the file path to have different caseing, i.e. my application is in C:/application but the resolved link (which node uses via require) is c:/application/... so the case of the drive letter changes for the api and everything _require_d from the api.
So even though I call "require('react')" both times I end up importing
C:/application/node_modules/react/...
and
c:/application/node_modules/react/...
which is obviously the same thing, yet it means react is loaded twice.
Now the ref that's triggering the error is also not added by me but by react-bootstrap which adds a string-ref.
So my code has no bug (I'm not using different react versions or different case when importing react in my code)
react-bootstrap doesn't do anything wrong (because string refs are still allowed).
node isn't doing anything wrong (since it documents that require isn't guaranteed to always return the instance.)
yarn isn't doing anything wrong (because on a case-insensitive filesystem there is nothing wrong with using different cases for the drive letter between link source and link target.)
react however relies on require always returning the same instance, which it can't.
What is the expected behavior?
React doesn't rely on behavior that is documented to be unreliable.