Enonic React pass values from jsx to es6

Enonic version: 7
OS: ubuntu 20.4

I want to pass values from jsx to es6 in enonic react application. I want that because I want to call an API /user/{id} like that and id needs to pass to function write in .es6 file.

Hi, cherysan19!

The answer depends on couple of things, just so we’re on the same page:

Is this a react4xp project - or some other way of connecting up react to XP?

And the es6 files, what are those? Especially, are they XP controllers (in general, run on the XP server)? Or source files compiled and run in the browser (in parallel with the react components from the jsx files, or even imported by them)?

In the most usual setup, a react4xp jsx that runs in the browser and an es6 file running on XP, the jsx will need to send the data asynchronously to XP through an API. What you’re suggesting sounds like it could be a regular API endpoint, for example an XP service or a mapped controller that receives the id by a POST request.

1 Like