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

requireNativeComponent: "R2RTouchThroughWrapper" was not found in the UIManager. #16

Open
KirDontsov opened this issue Mar 17, 2020 · 2 comments

Comments

@KirDontsov
Copy link

KirDontsov commented Mar 17, 2020

I did all the installation instructions, but get this error, what could it be?
2020-03-16_18-02-50

My MainActivity.java:

package com.onlinerecordtypescript;
package com.reactnativetouchthroughviewexample;

import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;

import android.view.MotionEvent;
import com.rome2rio.android.reactnativetouchthroughview.TouchThroughTouchHandlerInterface; 
import com.rome2rio.android.reactnativetouchthroughview.TouchThroughTouchHandler;

public class MainActivity extends ReactActivity implements TouchThroughTouchHandlerInterface {
    
    private TouchThroughTouchHandler touchThroughTouchHandler = new TouchThroughTouchHandler();
    /**
     * Returns the name of the main component registered from JavaScript.
     * This is used to schedule rendering of the component.
     */
    @Override
    protected String getMainComponentName() {
        return "onlineRecordTypeScript";
    }
    public TouchThroughTouchHandler getTouchThroughTouchHandler() {
        return touchThroughTouchHandler;
    }
    @Override
    protected ReactActivityDelegate createReactActivityDelegate() {
        return new ReactActivityDelegate(this, getMainComponentName()) {
            @Override
            protected ReactRootView createRootView() {
                return new RNGestureHandlerEnabledRootView(MainActivity.this);
            }
        };
    }
    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        touchThroughTouchHandler.handleTouchEvent(ev);

        return super.dispatchTouchEvent(ev);
    }
}

I'm using TypeScript.

I declared module in index.d.ts file:

/// <reference types="node" />

declare module "react-native-touch-through-view" {
  export const TouchThroughView = {} as any;
  export const TouchThroughWrapper = {} as any;
}

my component is:

const HomeScreen = (props: HomeScreenProps): JSX.Element => {
  return (
    <SafeAreaView
      style={props.darkTheme ? styles.containerDark : styles.containerLight}
    >
      <LightStatusBar />
      <TouchThroughWrapper style={styles.scrollWrapper}>
        <LoadAssets {...{ assets }}>
          <LinearGradient
            colors={
              props.darkTheme
                ? [blackColor, activeColor]
                : [activeColor, passiveColor]
            }
            style={styles.gradient}
          >
            <TouchThroughView
              style={{
                flex: 2,
                marginTop: 100,
                backgroundColor: "transparent"
              }}
            >
              <AppButton
                style={{ zIndex: 0 }}
                title="Записаться"
                onPress={() => props.navigation.navigate("Record")}
              />
            </TouchThroughView>

            <ScrollView style={{ zIndex: 2 }}>
              <Cities navigation={props.navigation} />
            </ScrollView>
          </LinearGradient>
        </LoadAssets>
      </TouchThroughWrapper>
    </SafeAreaView>
  );
};
@simonhoss
Copy link
Owner

simonhoss commented Mar 20, 2020

Hi

Did you add it also inside the getPackages() in MainApplication.java?

Like this:

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new TouchThroughViewPackage()
      );
    }

@simonhoss
Copy link
Owner

Also in this repo it's working: https://github.com/AndresAltomobile/TouchThroughViewAndroidIssueDemo

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

No branches or pull requests

2 participants