0

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 ?

John Stuart
  • 950
  • 5
  • 11
  • 28

1 Answers1

2
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'
Adnan Samir
  • 171
  • 5
  • Thanks, Seems like this way it works. It is not null now. Do you know why it is not working with my approach ? – John Stuart Jun 13 '21 at 07:53
  • 1
    I think it was an issue of import. If you import it like this : import NativeModules from 'react-native' it will show the data. – Adnan Samir Jun 13 '21 at 07:58
  • Yes now NativeModules is not empty. Are there any documents on `RecordComponent` ? I tried by searching but did not see any documentation. – John Stuart Jun 13 '21 at 08:03
  • Even I didn't find anything on it hence I suggested you to go for requireNativeComponent – Adnan Samir Jun 13 '21 at 08:12