open-rpc/docs-react

Example has an error, and does not work in node 16 (works in node 14)

bok11 opened this issue · 1 comments

bok11 commented

I have been trying to follow your example, but it does not seem to work.

I get

Failed to compile.

/workdir/test/src/index.ts
TypeScript error in /workdir/ll/test/src/index.ts(15,32):
'>' expected.  TS1005

    13 | };
    14 | 
  > 15 | ReactDOM.render(<Documentation schema={schema} />, document.getElementById("root"));
       |                                ^
    16 |

Steps to reproduce:

$ docker run --user $UID:$UID -p 3000:3000 -it -v $(pwd):/workdir node /bin/bash
$ cd workdir
$ yarn add typescript
$ npx create-react-app test --typescript
$ cd test
$ npm install .
$ npm install @open-rpc/docs-react @open-rpc/meta-schema --save
$ < use any editor to add index.ts>
$ npm start

I noticed that there are no .ts files present, though i i do
npx create-react-app test --template typescript
i will get index.tsx

This still fails with the same error though.

I tested in the latest node, and in node 14.

I can make it work in node 14 by using :
npx create-react-app test --template typescript

and editing index.tsx ( not renaming it to index.ts)

In node 16 when using --template, i get the following error:

Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.

Snippet for opening node14:
docker run --user $UID:$UID -p 3000:3000 -it -v $(pwd):/workdir node /bin/bash

bok11 commented

This works steps:

$ docker run --user $UID:$UID -p 3000:3000 -it -v $(pwd):/workdir node:14 /bin/bash
$ cd workdir
$ yarn add typescript
$ npx create-react-app test --template typescript
$ cd test
$ npm install .
$ npm install @open-rpc/docs-react @open-rpc/meta-schema --save
$ < use any editor to add index.ts>
$ npm start