美文网首页
2018-02-06 modifier--item

2018-02-06 modifier--item

作者: NOTEBOOK2 | 来源:发表于2018-02-06 11:11 被阅读0次
      componentWillMount() {
        const { modifierSetId, productIds } = this.props
        if (modifierSetId) {
          const items = []
          for (const i of productIds) {
            this.props.call(Actions.INIT, 
              { filters: [`products.id__equal__${i}`] })
            if (list[0]) {
              items.push(list[0])
            }
          }
          this.setState({ modifierItem: items })
        }
      }   
    

    the part of modifier-item

    import { Table, Col, AddIndicator, Action, SVGIcon,
     Loading } from "components"
    import { call } from "redux-saga/effects"
    import orchestra, { Type as ActionTypes } from "utils/orchestra"      
    
    interface Props {
      classes: Classes
    }
    
    interface IActionTypes {
      [key: string]: string
    }
    
    const Actions: IActionTypes = {
      INIT: "INIT",
    }
    
    interface Payloads {
      list: ModifierSet[]
    }
    
    type P = Props & WithStyles & StateProps & DispatchProps & WithOrchestra<Payloads> & Payloads   
    

    loading ? :

              {loading.list ? (
                <Loading />
              ) : (  
             )}
    

    The final part

    function* load(props: any) {
      if (props.modifierSetId) {
        const items = []
        for (const i of props.productIds) {
          const { list } = yield call(mainV2.store(props.storeId).listings.getItemList,
          {filters: [`products.id__equal__${i}`]})
          if (list[0]) {
            items.push(list[0])
          }
        }
        return items
      }
    }
    
    const OrchItem = orchestra<Props, Payloads>([
      {
        type: ActionTypes.INIT,
        action: Actions.INIT,
        prop: "list",
        runner: load,
        initParams: { filters: [`products.id__equal__314932`] }
      }
    ])(Item)    
    

    call的参数不是要执行的方法,去掉get()括号


    441517890547_.pic_hd.jpg
    [at-loader] ./src/pages/Inventory/Modifiers/Edit.tsx:99:20 
       TS2459: Type 'Readonly<{ children?: ReactNode; }>
    & Readonly<P>'
    has no property 'model' and no string index signature.
    

    the reason below

    interface Payload {
      model: ModifierSet
    }
    
    const Actions: IActionTypes = {
      INIT: "INIT",
      UPDATE: "UPDATE",
      DELETE: "DELETE"
    }  
    

    相关文章

      网友评论

          本文标题:2018-02-06 modifier--item

          本文链接:https://www.haomeiwen.com/subject/xlowzxtx.html