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

Expo & Bare RN haptic interop #3

Closed
jxom opened this issue Oct 7, 2021 · 2 comments · Fixed by #4
Closed

Expo & Bare RN haptic interop #3

jxom opened this issue Oct 7, 2021 · 2 comments · Fixed by #4
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest

Comments

@jxom
Copy link
Contributor

jxom commented Oct 7, 2021

Based on the discussion in #1.

It would be nice to have the ability to support haptic feedback in Expo managed projects (as well as bare React Native projects – which is what we support currently).

I think the ideal approach is @andreialecu's module detection technique. We should list expo-haptics (for Expo managed projects) and react-native-haptic-feedback (for bare RN projects) as optional peer dependencies, and if the library detects that expo-haptics is installed, then prefer that over react-native-haptic-feedback.

@jxom jxom added enhancement New feature or request good first issue Good for newcomers hacktoberfest labels Oct 7, 2021
@andreialecu
Copy link
Contributor

I just made an attempt to implement this but it seems that optional requires are broken in the latest Metro for some weird reason.

I've been running into:

Error: Requiring unknown module "undefined". If you are sure the module exists, try restarting Metro. You may also want to run `yarn` or `npm install`.

This seems to be tracked at: facebook/metro#666

Disabling inlineRequires didn't work, and doesn't seem like a good idea anyway.

So I think an alternative would be to simply remove the haptics implementation from the library and just provide a callback which the user can handle themselves to trigger haptics.

Meaning, instead of enableHapticFeedback, there would be a callback onHapticFeedback.

Or it could be more generic, so that the user could do:
onCurrentXChange={(value) => { if (value !== 0) { invokeHaptic() }}

andreialecu added a commit to andreialecu/react-native-wagmi-charts that referenced this issue Oct 7, 2021
Removes dependency on react-native-haptic-feedback
Allows user to provide their own haptics implementation

Closes coinjar#3
@jxom jxom closed this as completed in #4 Oct 7, 2021
jxom pushed a commit that referenced this issue Oct 7, 2021
Removes dependency on react-native-haptic-feedback
Allows user to provide their own haptics implementation

Closes #3

Co-authored-by: Andrei Alecu <andreialecu@users.noreply.github.com>
@nandorojo
Copy link
Contributor

nandorojo commented Oct 7, 2021

The onActivated and onEnded props are no-ops at the moment. I can PR this.

Actually I can't seem to figure out why this is.

simonitfi pushed a commit to simonitfi/react-native-wagmi-charts that referenced this issue Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers hacktoberfest
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants