medha
medha

Reputation: 97

react.js rendering react components on client side

I am using node.js with react.js as my templating library. I am able to render my components on server side by using node's res.render(..), but I want to make my components dynamic by rendering them on client side using react.js and calling the onclick handlers. I have my components defined in .jsx format. How can I interact with the browser in client side and render my react components dynamically?

Upvotes: 3

Views: 1780

Answers (2)

Aditya Singh
Aditya Singh

Reputation: 16710

You can start using it with ES6 class syntax using babel js. I have created a sample component here

You can also use react-starter-kit which gives you all the setup pre-loaded. A good place to start would be Facebook's react documentation

Upvotes: 0

Ezra Chang
Ezra Chang

Reputation: 1298

You will need to have your code transpiled and bundled, then you can insert it in a script tag just like any other script. One popular option is webpack; another is the use of Browserify with babelify in a gulp task.

Upvotes: 1

Related Questions