Under the header, I’d like a React container with my own custom JS code.
Question:
How can I do it without making a custom plugin for Discourse, but by only providing custom JS scripts in admin panel?
I’ll need to still keep the Discourse header live
Will I be able to subscribe to Discourse streaming API without using Ember?
As you can understand, the whole goal for me here is to make a custom page with the native Discourse header, but with using React.js and not touching Ember.js at all.
The ember router is JS, so I thought what if there is a way to add a route to it AND provide a template as well - such a template which would not make Ember request anything from the server, but just load react JS library and some custom JS files with React components?
Will it be possible to load the Discourse’s header section into that page and still have access to all the Discourse environment and streaming API from withing JS?
What you’re proposing would have to go through some circus like
Call to domain/my-page.html
Discourse 404’s
Your custom JS catches that 404, recognizes that it came from your custom route somehow, and… renders the whole template into the 404 div?
Meanwhile, it also loads a react component, which… I guess gets slid into a particular DOM element using react-dom-inject or something?
Then it subscribes to messageBus, err maybe by loading something like let messageBus = Discourse.__container__.lookup('messageBus:main').subscribe? (<-- this code I think still works today, but likely won’t forever, or even for much longer)
I don’t quite get it; why is creating a custom plugin, or using Ember, not an option here?
I get that the plugin architecture and perhaps Ember has a steep learning curve, but this is really using a to churn the butter.
Because I’m not a R programmer, nor am I an Ember programmer. In the same time, I have lots of React.js experience and I love building stuff with using it.
It’s not that learning Ember is difficult. It’s that I hate its paradigm, so would like to keep its usage to the minimum.
Okay, well, thanks for commenting - anyway, this one is not the critical point. What I wanted is to allow easy React embedding in particular Discourse pages.