piątek, 25 marca 2016

django -> react

I am thinking about big change right now,
being fed-up with fighting with django context path problem* I am thinking to switch to another backend solution
people are saying good things about React, why not react to that movement properly?
Let's try to check is it easy to run it home..

1) install all prerequisities
 * npm
 * browserify

2) run app as webserver?
Having knowledge based on this I get to know that react needs having webserver (express for example) to run on top of it, Frontside needs some index app having react scripts loaded and React classes created.  React app just has URL of endpoint created before and has pretty straightforward connection using code like that

ReactDOM.render(

  <CommentBox url="/api/comments" pollInterval={2000} />,

  document.getElementById('content')

);



Voila, react just works here..



* context path problem is when you have django app being runned by some magic Apache mod not on the server root / but some magic /django_subroot, then all the problems are happening about resources and security redirects