2017-12-14 7 views
0

私のMessageDialog内でSectionListへの紹介をthis.SectionListに保存します。 31行目でSectionListを許可するようにインターフェースを定義しようとしましたが、それは効果がありません。私は何をすべきか? MessageDialog.tsx(132,38): error TS2339: Property 'SectionList' does not exist on type 'SkademeldingDialog'反応クラスの関数のTypeScriptインターフェイスを定義する方法は?

29 interface IComponentProps { 
30 navigation: NavigationScreenProp<any, any>; 
31 SectionList: any; // I tried to add SectionList here, but that did not work. 
32 } 
33 
34 interface IDispatchToProps { 
35 requestHendelsesvelger: RequestHendelsesvelgerInterface; 
36 requestProsessguide: RequestProsessguideInterface; 
37 } 
38 
39 type Props = IComponentProps & IDispatchToProps; 

121 class MessageDialog extends React.Component<Props> { 

128 public render() { 
129 
130  return (
131  <SectionList 
132   ref={(sectionlist) => { this.SectionList = sectionlist; }} 
137  > 
138  </SectionList> 

答えて

1

Propsタイプではないコンポーネントインスタンス自体は、あなたがそこにSectionListを追加しないでください、あなたのコンポーネントでthis.propsを入力することです:

活字体は、と文句を言い。それはクラスのプロパティである必要があります。

class MessageDialog extends React.Component<Props> { 
    private sectionList: SectionList; 
    public render() { 

    return (
     <SectionList 
     ref={(sectionlist) => { this.sectionList = sectionlist; }} 
     > 
     </SectionList> 
+0

これはほとんど動作しました。 :-) 'MessageDialog.tsx(127,24):エラーTS2314:汎用型 'SectionList'には1つの型引数が必要です。私が 'private sectionList:any'を実行すると、警告は表示されません。どのように私は正しいタイプを得ることができる任意のアイデア? – martins

+0

私はDefinitelyTypedを追加しようとします。それはSectionListのためにタイプしているようです。 – martins

+0

あなたは正しいタイプのargsを追加しなければならないでしょう、SectionListを見ることなく、私は彼らが何であろうと言います。例: 'private sectionList:SectionList ' – wgcrouch

関連する問題