javascript - React - populating <li> error -


hello implement basic navigation in react, have following code:

edited .js

 var navigation = react.createclass({   getdefaultprops: function() {     return {       navigationitems: [         { 'id': 1, 'name': 'home', 'url': '/home' },         { 'id': 2, 'name': 'about', 'url': '/about' },         { 'id': 3, 'name': 'contact', 'url': '/contact' }       ]     };   },   render: function() {     return (       <nav>         <ul>           {this.props.navigationitems.map(function() {             return (               <li><a href={this.props.url}>{this.props.name}</a></li>             );           })}         </ul>       </nav>     );   } });  module.exports = navigation 

it's throwing me following error: uncaught typeerror: cannot read property 'props' of undefined. ideas why?

unless have in different component passed navigation, navigationitems not prop. should access calling navigationitems.map()


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -