I recently discovered the joy of stateless components. For example, this makes me quite happy (and it works):
import { Component, PropTypes } from 'react'; export default function ClassroomsOverview(props, context) { return ( <div> <p>{context.classrooms.data.length} Classrooms.</p> <p>{context.classrooms.members.length} Students</p> </div> ); } ClassroomsOverview.contextTypes = { classrooms: PropTypes.object }
I would be even happier if I could make the same component with the E6 arrow function syntax , for example:
import { Component, PropTypes } from 'react'; const ClassroomsOverview = (props, context) => ( <div> <p>{context.classrooms.data.length} Classrooms.</p> <p>{context.classrooms.members.length} Students</p> </div> ); ClassroomsOverview.contextTypes = { classrooms: PropTypes.object }
I watched this video , but I cannot get the version of the arrow syntax to work.
Can anyone point out what I'm doing wrong?
ecmascript-6 reactjs
U rsus
source share