javascript - What is var name = (param) => {} in JS -


i'm working react-router test stubbing example, , i've never seen class convention before. i'm guessing es6 specific?

var stubroutercontext = (component, props, stubs) => {     function routerstub() { }      object.assign(routerstub, {         makepath () {},         makehref () {},         transitionto () {},         replacewith () {},         goback () {},         getcurrentpath () {},         getcurrentroutes () {},         getcurrentpathname () {},         getcurrentparams () {},         getcurrentquery () {},         isactive () {},         getrouteatdepth() {},         setroutecomponentatdepth() {}     }, stubs);      return react.createclass({         childcontexttypes: {             router: react.proptypes.func,             routedepth: react.proptypes.number         },          getchildcontext () {             return {                 router: routerstub,                 routedepth: 0             };         },          render () {             return <component {...props} />         }     }); }; 

and why typeerror: object not function when this?

var subject = stubroutercontext(handler, props); 

here's link doc https://github.com/rackt/react-router/blob/master/docs/guides/testing.md

it es6 specific, it's arrow shorthand: https://github.com/lukehoban/es6features#arrows

"arrows function shorthand using => syntax. syntactically similar related feature in c#, java 8 , coffeescript."


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -