Skip to content

docs: update Hit Test tutorial to use getInputSourceState instead of deprecated useXRHandState #454

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

micronic85
Copy link

This PR updates the Hit Test tutorial (hit-test.md) to replace the deprecated useXRHandState hook with the current getInputSourceState approach from @react-three/xr.

Changes:

  • Replaced all references to useXRHandState with getInputSourceState
  • Adjusted related explanation text and code samples
  • Ensured consistency with current API usage

Let me know if any further tweaks are needed!

@bbohlender
Copy link
Collaborator

Thanks for the PR!

The correct hook in this case is "useXRInputSourceStateContext()", so the developer does not have to provide information about the input source type and its handedness because its provided through the context :)

@micronic85
Copy link
Author

Thanks for the clarification, @bbohlender!

That makes sense. Using useXRInputSourceStateContext() is indeed a better approach as it automatically retrieves the type and handedness from the context, simplifying the API for the user.

I've updated the PR to replace xr.getInputSourceState("hand", "right") with useXRInputSourceStateContext() as suggested.

const store = createXRStore({
  hand: {
    right: () => {
      const state = useXRInputSourceStateContext();
      // ...
    }
  }
});

This makes it clearer how the state retrieved from the context is then used within the hand configuration function.

@bbohlender
Copy link
Collaborator

@micronic85 I don't see the update you mentioned beeing applied to the files :)

@micronic85
Copy link
Author

@bbohlender, I've updated the code

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 this pull request may close these issues.

2 participants