javascript - Reactjs server side templates -


i wonder there way load react component template server?

when worked vuejs or other js-library have add code view , after rendered server javascript starts running , rest.

for instance, can type in symfony app localized string: {{ 'header.article_title'|trans }} , translated.

however, since templates hardcoded reactjs-component can not use php/symfony/twig functions anymore. so, i'm wondering if there way fetch template server angularjs templateurl-option.

finally how need.

i've realized possible not have actual file url. so, if need /react/component/article.js url action.

so, i've created new bundle, add controller , use 1 action view single react-component.

the skeleton code looks this:

/**  * class componentcontroller  * @package reactjsbundle\controller  *  * @route("/react/component")  */ class componentcontroller extends controller {     /**      * @route("/article.js")      */     public function articleaction()     {         $resp = new response();         $resp->headers->set('content-type', 'text/javascript');          return $this->render('reactjsbundle:component:article.html.twig', [], $resp);     } } 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -