React4xp error during rendering

I started the Server side JSX with React4XP - Enonic Developer Portal tutorial and stopped in the first render with the following error:


I checked the files and they have the same code as the tutorial

@Espen42 Any ideas about this?

Hi, Marcelo

Have you tried setting the buildEnv variable as described in the section for
react4xp.properties => buildEnv as described here: React4XP - API reference - Enonic Developer Portal

Best wishes,
Bjørnar

Hi, Marcelo!

This is interesting. @bhj is on the right trail, but there should be a working fallback in the system for whenever buildEnv is not used/found in react4xp.properties, so that shouldn’t be the problem. And the null and undefined parts of that message should be more useful, so it’s possible you’ve come across a bug.

Just to start by verifying some steps:

  • So what you have is a clean version of the react4xp-starter as described in the setup chapter of the react4xp guide? As in, the code has only been changed according to the steps in the guide up to the point where the rendering failed?
  • Please verify some important parts of the build setup (that should come with the starter, but just to make sure):
    • In package.json, you have version 2.0.0 of react4xp, version 5 of webpack and version 4 of webpack-cli?
    • In build.gradle, you have version 2.0.0 of the react4xp library, com.enonic.lib:lib-react4xp? Following the starter, that probably looks like…
      include "com.enonic.lib:lib-react4xp:${rootProject.ext.LIB_REACT4XP_VERSION}"`
      
      …where rootProject.ext.LIB_REACT4XP_VERSION is set to 2.0.0 just above.
    • In build.gradle, you have def react4xpGradlePath = 'node_modules/react4xp/react4xp.gradle', and apply from: react4xpGradlePath (or simply: apply from: 'node_modules/react4xp/react4xp.gradle'?)

If these are correct, we can continue looking for the problem more specifically.

Espen Norderud

1 Like

Yes, I uncommented the line and tried to run the project again, but the error persisted.

Exactly. I have the same code from the tutorial up to the point of trying to render (Hello React - server and clientside rendering - Enonic Developer Portal). All the lines you mentioned are set up correctly in the project.

I reproduced it locally. Thanks for bringing it to our attention, I will look at it immediately and see if it’s a recently introduced bug in the react4xp library or something wrong in the guide. :slight_smile:

Update: found and fixed the problem in lib-react4xp. I will test it further and release a bugfix update (probably version 2.0.1) for lib-react4xp and the starter.

In the meantime, I’ve uploaded it as a release candidate - version 2.0.1-RC1. It will exist on our server until I release the finished 2.0.1, so you can try to update the lib-react4xp version to 2.0.1-RC1 in your build.gradle and proceed with the guide from there, and change it to 2.0.1 when that’s released.

Hope this helps!

-Espen

2 Likes

Here, the fix is released now: React4xp is updated: 2.0.1
:slight_smile:

Thank you for your support. It worked!