Skip to content

'JsonViewer' cannot be used as a JSX component. #16

@pengbins

Description

@pengbins
$ npx create-react-app  demo  --template redux-typescript
$ cd demo
$ npm install @textea/json-viewer --save
$ vim src/App.tsx      

import JsonViewer from '@textea/json-viewer';

function App() {
  const src = {'aaa': 'bbb'};
  return (
    <div className="App">
        <JsonViewer src={src}  />
    </div>
  );
}

export default App;

$ npm run build

TS2786: 'JsonViewer' cannot be used as a JSX component.
  Its element type 'ReactElement<any, any> | Component<ReactJsonViewProps, any, any> | null' is not a valid JSX element.
    Type 'Component<ReactJsonViewProps, any, any>' is not assignable to type 'Element | ElementClass | null'.
      Type 'Component<ReactJsonViewProps, any, any>' is not assignable to type 'ElementClass'.
        The types returned by 'render()' are incompatible between these types.
          Type 'ReactNode' is not assignable to type 'Element | null'.
            Type 'undefined' is not assignable to type 'Element | null'.
     5 |   return (
     6 |     <div className="App">
  >  7 |         <JsonViewer src={src}  />
       |          ^^^^^^^^^^
     8 |     </div>
     9 |   );
    10 | }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions