没有启用ES7属性初始化程序的咖喱功能 [英] Curried function where ES7 property initializers aren't enabled

查看:194
本文介绍了没有启用ES7属性初始化程序的咖喱功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在所谓的 curried格式,取自此SO答案

const getIntervals = n=> availability=> {}

我需要在一个用ES6语法编写的不能处理ES7的React组件中使用它由于实施而导致的属性初始化器。

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

通常在React的类上下文中的一个函数具有这种简单的样式:

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

myFunction () {}

但是我会转换 getIntervals 函数

推荐答案

只需将 getIntervals 定义为常规方法,但是它返回你的咖喱功能:

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

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

      }
   }
   render() {...}
}

这篇关于没有启用ES7属性初始化程序的咖喱功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆