Skip to content

Double Props definition when working with TypeScript #22

Description

@SoftHai

Hi,

when working with TypeScript Components, it is needed to define the props definition twice:

  • As the TypeScript way (Interface and generic React Component React.Compoennt<PropsType>) for type checking in the code
  • As a PropTypes definitions for being reflected in the Webcodesk UI
import React from 'react';
import PropTypes from 'prop-types';

export interface CompProps {
    text: string;
}


class CompName extends React.Component<CompProps > {

    static propTypes = {

        text: PropTypes.string
      }

    static defaultProps = {
        text: "Hallo World"
    }

    render() {
        return <div>{this.props.text}</div>
    }
}

export default CompName;

It would be nice when for TypeScript compoenents the TypeScript Props definition could be used to show and reflect the definition in the Webcodesk UI. That would make maintenance easier.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions