Pass props from template into react.js root node

reactjs

Solution

No, though of course you can do:

var container = document.getElementById('content');
React.renderComponent(
  <Swoosh
    foo={container.getAttribute('foo')}
    bar={container.getAttribute('bar')}
    bav={container.getAttribute('bav')} />,
  container
);

(or if you want to make an attributes dict using something like https://stackoverflow.com/a/5282801/49485, then you can do `Swoosh(attributes)`).

Problem

I may have missed something, but here goes. If I have: ``` var Swoosh = React.createClass({ render: function() { return ( <div className="swoosh"> Boom. </div> ); } }); React.renderComponent( <Swoosh />, document.getElementById('content') ); ``` Can I set `props` as attributes on the mount point (where `id='content'`)? ``` <div id='content' foo='alice' bar='has' bav='a cat' /> <!-- have foo, bar & bav available as props in <Swoosh />? --> ```

Original source

Related problems