var React = require("react"); var ReactDOM = require("react-dom"); var Ribbon = require("./Ribbon.jsx"); var Article = React.createClass({ getInitialState: function() { return { sections: require("./sections") }; }, setSectionId: function(name, entry) { ReactDOM.findDOMNode(this.refs[name]).setAttribute("id", name); }, componentDidMount: function() { // Not sure why this doesn't just work by passing a props.id this.sectionMap(this.setSectionId); }, sectionMap: function(mapping) { return this.getSectionNames().map(mapping); }, getSectionNames: function() { return Object.keys(this.state.sections); }, generateSection: function(name, entry) { var Type = this.state.sections[name]; return ; }, generateNavItem: function(section, entry) { var name = section.props.name; return
  • { section.props.title }
  • ; }, render: function() { var sections = this.sectionMap(this.generateSection); return (
      { sections.map(this.generateNavItem) }
    { sections }
    ); } }); module.exports = Article;