Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better examples and codesandboxes #32

Open
giulioz opened this issue Sep 7, 2020 · 7 comments
Open

Better examples and codesandboxes #32

giulioz opened this issue Sep 7, 2020 · 7 comments
Labels
documentation Improvements or additions to documentation

Comments

@giulioz
Copy link
Member

giulioz commented Sep 7, 2020

They are pretty outdated and without good code standards

@giulioz giulioz added the documentation Improvements or additions to documentation label Sep 7, 2020
@haukesand
Copy link

Hi. I want to use your r3flex-jbgrq codesandbox example locally outside of codesandbox. However, I am not sure which typescript compiler options to use. The Text.tsx and scrollArea code part does not compile.
node --version v10.20.1
"target": "es2017",

@giulioz
Copy link
Member Author

giulioz commented Jan 31, 2021

@haukesand What errors are you getting?

@haukesand
Copy link

My steps:

  1. Clone and yarn install / start.
    /bin/sh: react-scripts: command not found
  2. yarn add react-scripts
    (automatically added tsconfig.json)
Failed to compile.

src/Text.tsx
  Line 19:9:  Parsing error: Unexpected token

  17 | type TextMesh = ReactThreeFiber.Object3DNode<TextMeshImpl, typeof TextMeshImpl>;
  18 |
> 19 | declare global {
     |         ^
  20 |   namespace JSX {
  21 |     interface IntrinsicElements {
  22 |       textMeshImpl: TextMesh;
^C

I was unable to find out what typescript and react-script versions codesandbox uses.

@haukesand
Copy link

haukesand commented Jan 31, 2021

I got it to compile if I do not import Text from .Text.tsx but from drei directly.
Add @types/react dependency and edit the typescript config:

   "strict": false,
    "noImplicitAny": false,
    "strictNullChecks": false,
    

Of course, the text layout is wrong now.

@saitonakamura
Copy link
Collaborator

saitonakamura commented Jul 27, 2021

@giulioz I've updated one of the codesandboxes to new versions/packages, but there's one thing I couldn't make work - some text aren't centered despite alignItems="center"
https://codesandbox.io/s/r3flex-forked-kbs4y?file=/src/App.tsx
If we can fix that we can use this updated example
The only thing I changes besides packages is to manually position the Flex in the upper right corner (position={[-vpWidth / 2, vpHeight / 2, 0]})

@giulioz
Copy link
Member Author

giulioz commented Jul 27, 2021

@saitonakamura
To center the text you can work on the <Text /> component, adding textAlign="center" prop

@saitonakamura
Copy link
Collaborator

Oh, alright, updated https://codesandbox.io/s/r3flex-forked-kbs4y?file=/src/App.tsx
Looks like it's working correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants