React app no longer loading with component

As SF support for third party frameworks in communities was poor we decided to implement it using the component like so

<ltng:require scripts="{!$Resource.react_app  + '/www/js/main.js'}"   
              beforeLoadingResources="{!c.preReact}"
              afterScriptsLoaded="{!c.startReact}" />

Which renders the app into a div with the id of “app”, this worked perfectly until the summer 18 update and now all of our sandboxes have this error:

TypeError: Cannot assign to read only property ‘parseInt’ of object ‘[object Object]’

It comes from “aura_prod.js:852” having an issue with the script.
This ran fine unchanged before the summer 18 update and runs perfectly locally and on non sf environments.

What could be causing this error? How do I fix it?

Answer

For anybody else with the same issue, for us it seemed to be that in the summer18 update some polyfills were added for their code and then ones for our code were conflicting, In particular parseInt prototype on Number.

So far the solution seems to be related to webpack, don’t use “babel-polyfill”, instead use “transform-runtime”.

If you are looking for something that won’t modify globals to be used in a tool/library, checkout the transform-runtime plugin.

transform-runtime docs

Attribution
Source : Link , Question Author : lindstrom1989 , Answer Author : lindstrom1989

Leave a Comment