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

Follow up #21 & #27 #29

Closed
kevinresol opened this issue May 26, 2020 · 2 comments · Fixed by #31
Closed

Follow up #21 & #27 #29

kevinresol opened this issue May 26, 2020 · 2 comments · Fixed by #31

Comments

@kevinresol
Copy link
Contributor

For #27, Sorry the alternative destructure strategy is actually problematic:

because it now passes undefined values to the transform control, e.g. enabled={undefined}, or showX={undefined}, causing very weird errors. Not expert of TS, is there a way to not pass undefined props to the control?

@gsimone
Copy link
Member

gsimone commented May 26, 2020

I'm not sure if I'm misunderstanding, but I think you could use something like pick
and omit from lodash https://lodash.com/docs/4.17.15#pick

import pick from "lodash.pick";
import omit from "lodash.omit";

const props = {
  showX: true,
  position: [1,2,3]
};

const transformOnlyPropNames = ["showX", "enabled"];

const transformProps = pick(props, transformOnlyPropNames);  // {showX: true}
const objectProps = omit(props, transformOnlyPropNames); // {position: Array[3]}

https://codesandbox.io/s/magical-villani-zfzlo?file=/src/index.js:0-334

kevinresol added a commit to kevinresol/drei that referenced this issue May 27, 2020
drcmda added a commit that referenced this issue May 27, 2020
Use lodash pick/omit to fix #29
@drcmda
Copy link
Member

drcmda commented May 27, 2020

merged the pr, published, too

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

Successfully merging a pull request may close this issue.

3 participants