0

I added a new component to my project via a private NPM package. It has the following dependencies as indicated in my project's system.config.js:

"npm:dialog@0.6.4": {
  "material-ui": "npm:material-ui@0.19.4",
  "prop-types": "npm:prop-types@15.6.0",
  "react": "npm:react@16.2.0",
  "whatwg-fetch": "npm:whatwg-fetch@1.1.1"
}

When I run my app I see the following console error:

invariant.js:21 Uncaught (in promise) Error: parentComponent must be a valid React Component
at invariant (invariant.js:21)
at unstable_renderSubtreeIntoContainer (react-dom.development.js:11680)
at RenderToLayer.renderLayer (RenderToLayer.js:119)
at RenderToLayer.componentDidMount (RenderToLayer.js:56)
at eval (ReactCompositeComponent.js:149)
at measureLifeCyclePerf (ReactCompositeComponent.js:52)
at eval (ReactCompositeComponent.js:148)
at CallbackQueue.notifyAll (CallbackQueue.js:34)
at ReactReconcileTransaction.close (ReactReconcileTransaction.js:31)
at ReactReconcileTransaction.closeAll (Transaction.js:73)
at ReactReconcileTransaction.perform (Transaction.js:39)
at ReactUpdatesFlushTransaction.perform (Transaction.js:30)
at ReactUpdatesFlushTransaction.perform (ReactUpdates.js:60)
at Object.flushBatchedUpdates (ReactUpdates.js:104)
at ReactDefaultBatchingStrategyTransaction.closeAll (Transaction.js:73)
at ReactDefaultBatchingStrategyTransaction.perform (Transaction.js:39)

Some googling leads me to believe that the fact that I have multiple versions of react installed in the project could be contributing to the error. My dependencies rely on multiple versions of react, specifically: v0.14.9, v15.4.2, v16.2.0 (which is the one added here as required by this new component) and v16.3.2. I also have react-dom v15.4.2 and v16.3.2 installed. Dan Abramov wrote here that there are issues with multiple versions of react attempting to coexist in the same project. Given that my project now contains a react version higher than 16.0.0 I ran the command:

jscodeshift -t react-codemod/transforms/React-PropTypes-to-prop-types.js <path>

This command is recommended by React when making the jump to v16+

The part of my render() function that contains this breaking component is as follows:

{this._showDialog() &&
              selectedItems.length > 0 && (
                <Dialog
                  acm={
                    selectedItems.length === 1
                      ? cachedObjects[selectedItems[0]].access
                      : {}
                  }
                  onSelect={(access) => {
                    this._onAccessSave(access)
                   }}
                  onCancel={()=>{}}
                  serviceBaseEndpoint={serviceEndpoint}
                  open={openAccess}
                  userObject={Auth.fetchUserIfNeeded(true)
                    .then(user => {
                      return user})
                  }
                >
                  <a
                    id="access-button"
                    onClick={this._onAccessClick}
                    title="Set Access"
                    {...this._getViewState(_thingSelected)}
                  >
                    <img src="icons/padlock.svg" />
                  </a>
                </Dialog>
              )}

How can I eliminate the console error? I have to imagine this issue is related to react versions and my app configuration. My dependencies that rely on these older versions of react are mission critical and cannot be replaced. They are also up to date even though they use the old react versions. Is this a resolvable issue given this information?

Bob Smith
  • 505
  • 3
  • 10
  • 27
  • My research is indicating that it is probably an issue in the material-ui library, how did you rule this out as the cause? – Shammoo May 07 '18 at 18:35
  • @Shammoo This could be the case as I do use material-ui in this project. I ruled that this component is at least causing the issue because before it was added the issue did not exist and a different component was in its place. Adding this component has introduced the error. – Bob Smith May 07 '18 at 18:42
  • I had a similar issue with the react-bootstrap library Dropdown; it was just straight up broken with the latest version of React. I ended up just rebuilding the component... Try v0.18.x and v0.20.x, it might be a one version incompatibility. – Shammoo May 07 '18 at 20:25
  • @Shammoo v0.18.x and v0.20.x of which package? react? – Bob Smith May 07 '18 at 21:09
  • Sorry, I was advocating playing with the material-ui version. Verifying that it isn't a temporary issue with that library. – Shammoo May 08 '18 at 22:55

0 Answers0