Skip to content

Confused react type names on Flow and Typescript #395

Open
@xiaoshuangLi

Description

@xiaoshuangLi

Hi, I try convert react-docgen props to JSON-schema. But in typescript and flow, we get different names by different ways to program.Just like this. This ReactReactNode makes me so confused. How should i do with it ?

import React, { ReactNode, Component } from 'react';

interface Props {
  content: ReactNode,
  children: React.ReactNode,
}

class TSReactComponent extends Component<Props> {
  render() {
    return (
      <div>hello world</div>
    );
  }
}

export default TSReactComponent;

react-docgen result

{
  "description": "",
  "displayName": "TSReactComponent",
  "methods": [],
  "props": {
    "content": {
      "required": true,
      "flowType": {
        "name": "ReactNode"
      },
      "description": ""
    },
    "children": {
      "required": true,
      "flowType": {
        "name": "ReactReactNode",
        "raw": "React.ReactNode"
      },
      "description": ""
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions