3

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?

1
  • I am doing this. Instead of using react as just a templating library (like the Hapi react plugin) I went down the route of creating a proper Universal React configuration. It's quite complicated to set up initially but it's amazing when you get going. Check out this example: github.com/choonkending/react-webpack-node Commented Apr 18, 2016 at 13:29

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.