Skip to content

compile error "error TS2339: Property 'props' does not exist on type 'Dialog'" #13415

@SunShinewyf

Description

@SunShinewyf

I have an error when compile ts file, and I still do not know how to solve it after searching some references, any ideas?
my code is as follows:

import * as React from 'react'
import { View, Text, Image, TouchableOpacity, StyleSheet } from 'react-native'
import * as CONST from '../../CONST'

/**定义组件props */
export interface props{
    isVisible: boolean
    closeDialog?: () => void
}

export interface States {
}
export class Dialog extends React.Component<props,States>{
    constructor(props: props) {
        super(props);
    }
    static defaultProps = {
        isVisible: false
    };
    render() {
        return (
            this.props.isVisible ?
                <TouchableOpacity style={[styles.container, { width: CONST.WIDTH, height: CONST.HEIGHT }]} onPress={this.props.closeDialog.bind(this)}>
                </TouchableOpacity>
                : null
        )
    }
}
const styles = StyleSheet.create({
    container: {
        position: 'absolute',
        zIndex: 1000,
        top: 0,
        left: 0,
        right: 0,
        bottom: 0,
        backgroundColor: 'rgba(0,0,0,0.2)'
    }
})

but when I compile it, the console page gets an error like this :

js/components/dialog/dialog.component.tsx(19,18): error TS2339: Property 'props' does not exist on type 'Dialog'

the completed demo code address is here

Metadata

Metadata

Assignees

No one assigned

    Labels

    ExternalRelates to another program, environment, or user action which we cannot control.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions