Skip to content

Commit

Permalink
add constant for native component name
Browse files Browse the repository at this point in the history
  • Loading branch information
alimek committed Jun 6, 2019
1 parent 4dbbd92 commit f89e765
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/src/InteractableView.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React, { Component } from 'react';
import ReactNative, { requireNativeComponent, Animated, NativeModules, UIManager, Platform } from 'react-native';

const NATIVE_COMPONENT_NAME = 'InteractableView';
// this is required in order to perform imperative commands
const NativeViewManager = NativeModules.InteractableViewManager;

const NativeInteractableView = requireNativeComponent('InteractableView', null);
const NativeInteractableView = requireNativeComponent(NATIVE_COMPONENT_NAME, null);

class WrappedInteractableView extends Component {
render() {
Expand Down Expand Up @@ -73,7 +74,7 @@ class WrappedAnimatedInteractableView extends Component {
} else if (Platform.OS === 'android') {
UIManager.dispatchViewManagerCommand(
ReactNative.findNodeHandle(this),
UIManager.getViewManagerConfig('InteractableView').Commands.setVelocity,
UIManager.getViewManagerConfig(NATIVE_COMPONENT_NAME).Commands.setVelocity,
[params],
);
}
Expand All @@ -85,7 +86,7 @@ class WrappedAnimatedInteractableView extends Component {
} else if (Platform.OS === 'android') {
UIManager.dispatchViewManagerCommand(
ReactNative.findNodeHandle(this),
UIManager.getViewManagerConfig('InteractableView').Commands.snapTo,
UIManager.getViewManagerConfig(NATIVE_COMPONENT_NAME).Commands.snapTo,
[params],
);
}
Expand All @@ -97,7 +98,7 @@ class WrappedAnimatedInteractableView extends Component {
} else if (Platform.OS === 'android') {
UIManager.dispatchViewManagerCommand(
ReactNative.findNodeHandle(this),
UIManager.getViewManagerConfig('InteractableView').Commands.changePosition,
UIManager.getViewManagerConfig(NATIVE_COMPONENT_NAME).Commands.changePosition,
[params],
);
}
Expand All @@ -107,7 +108,7 @@ class WrappedAnimatedInteractableView extends Component {
if (Platform.OS === 'android') {
UIManager.dispatchViewManagerCommand(
ReactNative.findNodeHandle(this),
UIManager.getViewManagerConfig('InteractableView').Commands.bringToFront,
UIManager.getViewManagerConfig(NATIVE_COMPONENT_NAME).Commands.bringToFront,
[],
);
}
Expand Down

0 comments on commit f89e765

Please sign in to comment.