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

feat: add Helper component, declarative alternative to useHelper #1603

Merged
merged 1 commit into from
Mar 7, 2024

Conversation

isaac-mason
Copy link
Member

@isaac-mason isaac-mason commented Aug 7, 2023

Why

Provide a declarative alternative to the useHelper hook

What

Added a component <Helper /> that lets you add helpers declaratively

Example using <Helper />:

const Scene: React.FC<StoryProps> = ({ showHelper }) => {
  return (
    <Sphere>
      <meshBasicMaterial />

      <Helper type={BoxHelper} args={['royalblue']} />
      <Helper type={VertexNormalsHelper} args={[1, 0xff0000]} />
    </Sphere>
  )
}

Example using useHelper:

const Scene: React.FC<StoryProps> = ({ showHelper }) => {
  const mesh = React.useRef()
  useHelper(mesh, BoxHelper, 'royalblue')
  useHelper(mesh, VertexNormalsHelper, 1, 0xff0000)

  return (
    <Sphere ref={mesh}>
      <meshBasicMaterial />
    </Sphere>
  )
}

Checklist

  • Documentation updated (example)
  • Storybook entry added (example)
  • Ready to be merged

@vercel
Copy link

vercel bot commented Aug 7, 2023

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

Name Status Preview Comments Updated (UTC)
drei ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 9, 2023 1:54pm

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 7, 2023

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.

Latest deployment of this branch, based on commit de82e2e:

Sandbox Source
funny-chaplygin-95jnjt Configuration
Ground reflections and video textures Configuration
arc-x-pmndrs-colors Configuration

Copy link

github-actions bot commented Mar 7, 2024

🎉 This PR is included in version 9.101.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

2 participants