pmndrs / drei

🥉 useful helpers for react-three-fiber
https://drei.pmnd.rs/
MIT License
7.85k stars 641 forks source link

useHelper RefObject (non-mutable) #1945

Closed abernier closed 2 months ago

abernier commented 2 months ago

Why

Passing a mutable ref={} makes TS complains, here in the story:

image

What

so, I've naively convert useHelper's 1st param object3D into a simple RefObject (rather a MutableRefObject)

before after
image image

Checklist

I'm really not sure, how "safe" this is / how required this ref was to be mutable...

vercel[bot] commented 2 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
drei ✅ Ready (Inspect) Visit Preview May 1, 2024 9:11am
codesandbox-ci[bot] commented 2 months ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

CodyJasonBennett commented 2 months ago

This is actually what the React 19 types do since useRef can lead to confusing mutable/immutable types.

abernier commented 2 months ago

This is actually what the React 19 types do since useRef can lead to confusing mutable/immutable types.

IIUC, this PR is useless? (handled by next React19 updated types)

CodyJasonBennett commented 2 months ago

Yes, this will be resolved by React 19 and the next major of both R3F/Drei. #1941