Replies: 4 comments 1 reply
-
For context, especially for those who're not familiar with Miniplex: for this to work, the child component within I'm 100% positive that this used to work, so I'm guessing some newer version of r3-rapier no longer forwards a ref to the created rigidbody? |
Beta Was this translation helpful? Give feedback.
-
Hey, is there any updates on this or any work around that I could implement? I'm new to react so I'm not sure how to move forward from this. I believe the matter should be urgent, since ECS are used in games and rapier is a physic engine for games, which goes hand in hand. |
Beta Was this translation helpful? Give feedback.
-
In another library, I've been able to capture import React from "react";
const Example = (props) => {
const [childRef, setChildRef] = React.useState();
const refCatpureProps = useMemo(() => {
return {
ref: setChildRef,
}
}, [])
if (props.children) {
const child = React.Children.only(props.children);
return React.cloneElement(child, refCatpureProps);
}
return null;
}; For comparison, miniplex is doing something like this right now: import React from 'react'
const mergeRefs =
<T>(refs: Array<React.Ref<T>>): React.Ref<T> =>
(v: T) => {
refs.forEach((ref) => {
if (typeof ref === "function") ref(v);
else if (!!ref) (ref as any).current = v;
});
};
const Example = (props) => {
const ref = React.useRef(null)
if (props.children) {
const child = React.Children.only(props.children)
return React.cloneElement(child, {
ref: mergeRefs([child.ref, ref])
})
}
return null
}; I'm not sure what the implications are for each approach. If I understand correctly, the Curious what others think! |
Beta Was this translation helpful? Give feedback.
-
Did anyone find a workaround for this issue? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Has anyone been able to make newer versions of react-three-rapier work with miniplex?
It used to be really simple up until some recent version I think (after at least 0.9). Here's how you'd assign a RigidBody to an entity component:
For some reason this no longer works. Some context from the miniplex repo:
hmans/miniplex#303 (comment)
Beta Was this translation helpful? Give feedback.
All reactions