I am new in React Native, here is my problem: I want to start an activity by calling NATIVE code from REACT NATIVE on a button click.
I am getting an error, says on the JS console 'cannot read property \'startActivity\'of undefined.
...MORE CODE...
import ActivityStarter from './ActivityStarter'
...MORE CODE...
<Button
onPress={() => ActivityStarter.startActivity()}
title='Login' />
on the Java end:
public class ActivityStarterModule extends ReactContextBaseJavaModule {
public ActivityStarterModule(ReactApplicationContext reactContext) {
super(reactContext);
}
@Override
public String getName() {
return "ActivityStarter";
}
@ReactMethod
public void startActivity() {
ReactApplicationContext context = getReactApplicationContext();
Intent intent = new Intent(context, DashBoardScreen.class);
context.startActivity(intent);
}}