Can i use react component in edge template?

Hello All Sir
im adonis and nodejs starter.

I have route that routes
for all posts , post detail

in post detail i want to change only ui not route
eg when user comment i will change ui only.
when user like post
when user click pagination.

its not spa
i want to use react component in some part of project
thanks you

#i am devnoob

Hmm, that’s fully frontend thing then :slight_smile:

Yesh you can. I’ll give you some pseudo-code:

fetch('ajax-endpoint')
  .then(function (response) {
    response.json(function (payload) {
      const element = document.getElementById('id-of-thing-where-i-want-update')
      element.innerText = payload
    })
  })

First do request with fetch, then serialize it into JSON (assuming your API responds with JSON)
Then get element what you want to update and then replace element innerText with payload from server

1 Like

thanks you sirs