0

I want to save a referral to SectionList on this.SectionList within my MessageDialog. I have tried to define the interface to allow SectionList on line 31, but that has no effect. What should I do?

TypeScript complains that: MessageDialog.tsx(132,38): error TS2339: Property 'SectionList' does not exist on type 'SkademeldingDialog'

 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 Answer 1

1

The Props type is to type this.props in your component not the component instance itself, you shouldn't add the SectionList there. It should be a property on the class, that way it will exist on the MessageDialog type:

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

    return (
      <SectionList
        ref={(sectionlist) => { this.sectionList = sectionlist; }}
      >
      </SectionList>
Sign up to request clarification or add additional context in comments.

3 Comments

That did almost work! :-) MessageDialog.tsx(127,24): error TS2314: Generic type 'SectionList' requires 1 type argument(s).. If I do private sectionList: any, then I get no warnings. Any idea how I can get the type correct?
I'll try to add DefinitelyTyped. Looks like it has typing for SectionList.
You would have to add the correct type args, Without seeing SectionList I cant say what they would be. eg private sectionList: SectionList<Type>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.