仅指类型,但在此处用作值

时间:2018-02-27 15:09:20

标签: reactjs typescript react-native redux react-redux

我在编写这个React Native应用程序时使用的是TypeScript。 尝试创建一个简单的操作,将字符串作为参数并更新状态。但我得到了这个我不明白的错误。

的src /容器/ DamageClaimReceipt.tsx

import * as React from "react"
import { Text, View } from "react-native"
import { Question } from "../components/Question"
import GjeButton from "../components/GjeButton"
import { bindActionCreators, Dispatch } from "redux"
import { connect } from "react-redux"
import {
  SetDamageClaimReceiptNrAction
} from "../actions/processguide"

const mapDispatchToProps = (dispatch: Dispatch<any>) => bindActionCreators({
  setDamageClaimReceiptNr: SetDamageClaimReceiptNrAction,
  // 'SetDamageClaimReceiptNrAction' only refers to a type, 
  // but is being used as a value here.
}, dispatch)

class DamageClaimReceipt extends React.Component<any, any> {
  public render() {
    return (
      <View>

       <GjeButton
        title={"Set DamageClaimReceiptNr"}
        onPress={ () => this.props.setDamageClaimReceiptNr("100") }
      />

      </View>
    )
  }
}

export default connect<null, null>(
  null,
  mapDispatchToProps,
)(DamageClaimReceipt)

的src /动作/ processguide.ts

 10 export type SetDamageClaimReceiptNrAction =
 11   (damageClaimReceiptNr: string) => ISetDamageClaimReceiptNrAction
 12
 13 export interface ISetDamageClaimReceiptNrAction {
 14   type: actionTypes.SET_PROCESSGUIDE_RECEIPT_NR_FOR_CLAIM
 15   receiptNrForClaim: string
 16 }

1 个答案:

答案 0 :(得分:0)

jQuery(document).ready(function($){ $('.require').bind("propertychange change click keyup input paste", function(event){ THIS = $(this); validate(); if(no_error_remaining()) $('.common-success-msg').show(); }); }); function validate(){ if(is_empty()) set_warning(); else unset_warning(); } function is_empty(){ if(THIS.hasClass('raio-group')) return radio_is_unchecked(); else if(THIS.hasClass('input-group')) return is_input_group_not_set(); else if(THIS.hasClass('wp-editor-area')){ return editor_content_is_empty('frontier_post_content'); } else return is_value_not_set(); } function radio_is_unchecked(){ var name = THIS.find("input").attr("name"); if($("input:radio[name="+name+"]:checked").length == 0) return true; return false; } 定义方法签名,当调用Syntax error, unrecognized expression: input:radio[name=fp_tax_category[]]:checked将对象文字传递给方法时,使用SetDamageClaimReceiptNrAction属性,该属性不能具有函数签名的值,它可以是一个功能。

bindActionCreators