Fellow Stranger Fellow Stranger - 1 year ago 53
Javascript Question

Curried function where ES7 property initializers aren't enabled

I have the following arrow function in a so called curried format, taken from this SO answer:

const getIntervals = n=> availability=> {}

I need to use it in a React component, written in ES6 syntax, that cannot handle ES7 property initializers due to the implementation.

"Normally" a function in a class context in React has this simple style:

myFunction () {}

But would I convert the
function to this style?

Answer Source

Just define getIntervals as a regular method, but have it return your curried function:

class Example extends Component {
   getIntervals(n) {
      return (availability) => {

   render() {...}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download