React native RecordScreen Native Module is null - android

I want to use RecordScreen NativeModule in my react native app.
import {NativeModules} from 'react-native'
console.log(NativeModules) // This is empty {}
console.log(NativeModules.RecordScreen) // This is null
Currently I'm testing on android device yarn android build.
What is the reason for NativeModules is empty and NativeModules.RecordScreen is null ?

import {requireNativeComponent} from 'react-native';
const RecordComponent = requireNativeComponent('RecordComponent')
console.log(RecordComponent);
Try this instead
or if you wish to use the same one you can also do it like this:
import NativeModules from 'react-native'

Related

How do I use realm with react-native correctly?

I have a "small" problem trying to use realm in combination with my react-native app.
I just started with react native and I have installed and updated everything I need for development.
I installed first realm with the command
npm install realm
after that I followed the tutorial given by MongoDB.
But all I get is this error:
Unexpected identifier 'realm'. Expected ';' after variable declaration
After that I tried to look at a template provided by #realm/react.
I installed it and started to build the aplication on my phone via react-native run-android
But I get the exact same error without changing anything.
does realm only work with a specific version of react-native?
or am I doing somthing wrong?
I am getting that error even by just declaring a scheme.
import React, { useState } from 'react';
import { View, Text, StyleSheet, TouchableOpacity,ScrollView, Image, Alert } from 'react-native';
import { NavigationContainer } from '#react-navigation/native';
import { createStackNavigator, TransitionPresets, CardStyleInterpolators } from '#react-navigation/stack';
import { Icon, Button } from "#rneui/themed";
import { styles } from './CSS/style';
import Realm from "realm";
const TaskSchema = {
name: "Task",
properties: {
_id: "int",
name: "string",
status: "string?",
},
primaryKey: "_id",
};

Material Ui - Uncaught Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function

When I am loading this LoginScreen.js I m getting the above mentioned exception.
Before that I had installed
npm install #material-ui/core
import React from 'react';
import {Button} from '#material-ui/core/Button';
import { View } from 'react-native';
export default function LoginScreen() {
return (
<View>
<Button></Button>
</View>
);
}
You need to import differently. Try as the following:
import Button from '#material-ui/core/Button';
// or
import { Button } from '#material-ui/core';
Check from the official documentation here: Button API - Import.
I hope this helps!

Integrating react native app with smooch api

I am trying to integrate my react native app with smooch.io following this instructions. I have succesfully installing the module and configure MainApplication.java. Now i have problem when trying to show the conversation screen. Where should i put Smooch.show() in my react native app? Here is my index.android.js
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
View
} from 'react-native';
import Smooch from 'react-native-smooch';
export default class SmoochTest extends Component {
componentDidMount() {
Smooch.show();
}
render() {
return (
<View style={styles.container}>
</View>
);
}
}
const styles = StyleSheet.create({
// some style
});
AppRegistry.registerComponent('SmoochTest', () => SmoochTest);
I ran into a similar issue - did you link it? react-native link react-native-smooch. That solved it for me.

react-native import component from another component

i have project in react-native and its ok , my problem is when i tried to import component in another component its failed but when import at index.android.js its ok why ??
index.android.js
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
TextInput,
TouchableOpacity,
ToastAndroid,
ListView,
Navigator,
} from 'react-native';
import LoginView from './App/LoginView';
its ok but when tried to import the same in another screen like this
import React, { Component } from 'react';
import {
StyleSheet,
ToolbarAndroid
,AppRegistry,
View,
Text,
TouchableHighlight,
TextInput,
ListView,ActionButton,
Image
} from 'react-native';
import LoginView from './App/LoginView';
export default class MyOrders extends Component
{
i got this error , "Ruquring unknown module if you are sure the module is there try to restarting the packeger or running npm install" ????
Possible cause may be relative path('./App/LoginView') could be wrong with respect to the component while importing.Try updating the relative path accordingly.After updating stop the react-native dev server and again start it using react-native start.
Let us consider that you are importing AboutUs page in index.ios.js
by using the following
var AboutUs = require('./Views/AboutUs');
AboutUs.js is located in "Views" directory which is located in place where index.ios.js page located. And in AboutUs.js page you have to export the component by
module.exports = AboutUs;
Where,
class AboutUs extends Component {
.....
}

Can react native require a javascript module that downloaded from the internet dynamically?

I want to write an app that can dynamically require a javascript module that downloaded from the internet.For example,the app downloads a simple js module via react-native-fs's downloadFile function ,the js module as follows:
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
} from 'react-native';
module.exports = class Hello extends Component {
render() {
return (
<Text>Hello World.</Text>
);
}
}
How could I use the Hello class as a component in index.android.js file? I just want to execute the code dynamically.
As far as I konw, to use the js module, I have to require or import the js module. However, I can not require the file or import the js module(I guess I can only require the js module that bundled into the js bundle).
Does react native support this feature? I know react native can dynamically downloads js bundle from the internet. Does it support a single js file and execute the js module?
Any opinion is appreciated !

Categories

Resources