You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Can't get the react app to render on the WP page. #2
Bitnami's WordPress 5.7.1 that comes with AWS Lightsail.
Whether I create the react app within the instance (running CRA in /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/reactpress/apps) and build - development mode - or copy pre-built build directory to /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/reactpress/myappbuild - deployment mode,
the assigned slug (under /app1/) does render the root div as follows:
<!-- Please don't change. Block is needed for React app. -->
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
but doesn't include the related CSS/JS, which results in a blank page.
Can you please help me troubleshoot what goes wrong?
I followed the instructions as well as youtube video to the T, and verified that shell_exec is available.
First, just to be sure, however you create the app on your Lightsail instance the built directory needs to be in /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/reactpress/apps/[appname]/build.
Second, you created a react app in your localhost inside WordPress and gave it a name and a page slug and it worked? It is located in [path/to/devserver]/htdocs/wp-content/plugins/reactpress/apps/[appname]/build?
Now in the page source you refered to are there any html tags with an id starting with rp-react-app-asset? If yes, could you please post them here?
bitnami@ip-172-26-5-97:/opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/reactpress/apps/app1$ ls
build node_modules package.json package-lock.json public README.md src
I created the react app on a WP instance (not localhost), gave it the name app1 / slug app1 and when I go to the /app1/ URL and view source, I see the root div, but no other assets. I created an app2 by copying the build directory from app1, to /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/reactpress/apps/app2/build. Going to /app2/ gives the same behavior as /app1/: root div present, no assets.
Activity
rockiger commentedon Apr 28, 2021
Thanks for reporting this.
First, just to be sure, however you create the app on your Lightsail instance the built directory needs to be in
/opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/reactpress/apps/[appname]/build.Second, you created a react app in your localhost inside WordPress and gave it a name and a page slug and it worked? It is located in
[path/to/devserver]/htdocs/wp-content/plugins/reactpress/apps/[appname]/build?Now in the page source you refered to are there any html tags with an id starting with
rp-react-app-asset? If yes, could you please post them here?oozie commentedon Apr 28, 2021
I appreciate your quick response.
I created the react app on a WP instance (not localhost), gave it the name app1 / slug app1 and when I go to the
/app1/URL and view source, I see the root div, but no other assets. I created an app2 by copying thebuilddirectory from app1, to/opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/reactpress/apps/app2/build. Going to /app2/ gives the same behavior as /app1/: root div present, no assets.As per above, no assets in view-source.
rockiger commentedon Apr 28, 2021
Yeah this look good. I don't know what the problem is. This seems very odd.
Do have a debug log in WP instance?
oozie commentedon Apr 28, 2021
I added log statements to the code and stepped through it. The code expects
entrypointsin asset-manifest.json:reactpress/public/class-reactpress-public.php
Lines 150 to 151 in 86d2c51
but my asset-manifest.json looks like this:
oozie commentedon Apr 28, 2021
I must have used an old version of CRA. A rebuild on the more recent version is starting to work, but my SVG is missing.
oozie commentedon Apr 28, 2021
Essentially, it's working though - I'll replace it with a static asset from somewhere else.
Thanks for this awesome plugin, @rockiger.
rockiger commentedon Apr 29, 2021
Glad it works for you.
It seems to me, that something with your PUBLIC_URL is of. ReactPress changes the build command in the
package.jsonin every React app.The build line should looke like:
"build": "PUBLIC_URL=/wp-content/plugins/reactpress/apps/[app-name]/build react-scripts build",