Limenius/ReactBundle

TypeError: Cannot read property 'replace' of undefined

imikay opened this issue ยท 14 comments

An exception has been thrown during the rendering of a template ("Something went wrong evaluating JS code: result: "TypeError: Cannot read property 'replace' of undefined"")

Hi, do you had this error before? This error blocks me for two days, still don't know how to solve it, this is the only error message I got, no other information.

Maybe this is not a ReactBundle issue, but I don't know where else to ask.

Thanks.

That is an error produced when evaluating the JavaScript code on server side rendering. The problem is that when server side rendering the error trace is difficult to understand because it is referencing a temporary file without sourcemap.

To debug it you could set up only client side rendering and in the javascript console there should appear the same error, indicating the line where it is produced.

It could be something related to this bundle or something in your code, it is just indicating that there was an error found in the JavaScript part.

Also trace ({{ react_component('RecipesApp', {'props': props, 'trace': true}) }}) may help

Tried both, still no progress ๐Ÿ˜• .

As long as I put {{ react_component('RecipesApp', {'props': props, 'trace': true}) }} in the template, this error will persist. My node version is v4.4.2 and npm is v2.15.0, I am going to drop this for a few days, then look into this problem again. The symfony-react-sandbox runs just fine though.

Thanks for the help.

Does it work adding the option 'rendering': 'client-side' ({'props': props, 'trace': true, 'rendering': 'client-side'})? That should run the code client-side and give a more helpful error message in the javascript console of Chrome dev inspector.

Oh, I misunderstood your meaning of rendering client before, just tried this, no erors in the console.

No generated React view on the page either, I checked the source and only say this on the page
qq20160412-1

Maybe there's something wrong with my setting up process?

I think that it may be an error in your react code, that prevents the component from rendering. For some reason the component is not rendering. If I were you, I would try to rendering the component client-side without the bundle, in a normal fashion with only react, and see if it renders, or gives an error, or what.

Or, if you could publish in github the simplest case that reproduces this error, that I can Install and try, I can have a look at it.

I have pushed a new version just now (v0.8.4). Maybe it solves your problem, when rendering only client side as I saw that it was messing with the configuration when rendering only client side.

Thanks, I will update the bundle and try again. ๐Ÿ‘

There's a dependency issue:

Using version ^0.8.4 for limenius/react-bundle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- The requested package nacmartin/phpexecjs == 0.8.4.0 is satisfiable by nacmartin/phpexecjs[v0.8.4] but those are rejected by your minimum-stability.

composer.json settings, and with minimum stability set to dev

    "limenius/react-bundle": "^0.8.4",
    "nacmartin/phpexecjs": "^0.8.5"

Delete and reinstall the bundle solved the dependency problem, sorry to bother.

I guess the problem is the lack of mounting code which mounts React module into the page, I am working in a hybrid environment, only part of the page is using React, I created a public repository here react-bundle-integrate, you can check it out.

Thanks for taking your valuable time for helping me, I'm really appreciated it.

Ok, I have been digging into this. It works with "react-on-rails": "^4.0.0" in package.json. Looks like with version 5 there is a problem rendering console messages inside that package (nothing very important, but annoying), or in the integration of this bundle with them. I will work in the next days into making this package compatible with version 5 or, if they have a bug, I'll try to report it to them.

For the moment, using version 4 should be fine, I think.

Yes, react-on-rails 4.0 works for me, thank you for your time and patience. ๐Ÿ‘

By the way, I think we should put the version requirement of the dependencies in the doc to prevent further problems like this. Thanks.