• Resolved hammaadmemon

    (@hammaadmemon)


    I’m working through the getting started tutorial and am having trouble with the “Using the REST API” step. I’m getting the error reactPress is not defined in api.js when opening the page on localhost.

    I tried building and viewing the app on the Local WP server but that also fails and gives me an obscure error (since the code is minified after build).

    Here is the tutorial that I’m following: https://rockiger.com/en/reactpress/reactpress-tutorial/

    Do I have to import the reactPress variable somehow? It’s supposed to be global but doesn’t seem to be accessible from any .js file in src.

    Any help would be appreciated!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author rockiger

    (@rockiger)

    Could you look into the content of the index.html? And search for var reactPress? It should be defined there.
    If not look at the source of your WordPress page where you want to embed the React app. Is it present there?

    Hi @rockiger @hammaadmemon , I ran into the same problem.

    The ReactPress global var is not set in the dev-environment. You should be able to set it in the plugin admin screen on the WordPress install, but that doesn’t work for me. I assume that is because I work on a Windows machine.

    The reactpress var is however still set in the production environment on my install, so it runs on WordPress once you build it.

    If you have other causes or solutions, I would love to hear it.

    Plugin Author rockiger

    (@rockiger)

    @juust Thanks for posting this. I have unfortunately now Windows system where I can debug problems.

    A casual solution would be to a set the reactPress var by hand in the index.html. The drawback of this approach is, that you have to repeat it every time you update the the dev environment from ReactPress.

    Thanks for the reply @rockiger.

    Once I added a second and third appdirectory and page, it did allow me to set the index.html var.

    • This reply was modified 1 year, 5 months ago by juust.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘reactPress not defined’ is closed to new replies.