Danyal Banaras
Danyal Banaras

Reputation: 21

undefined is not an object (evaluating '_reactNativeRecordScreen.RecordScreen.StartRecording'

I am working on a react native project with expo.

I want to add screen recording in my app which starts recording screen when a button is pressed. I've used a package named "react-native-record-screen" for this.

I've installed this package with: "npm install react-native-record-screen"

but when I press the button to start recording, it gives the following error: "undefined is not an object (evaluating '_reactNativeRecordScreen.RecordScreen.StartRecording'"

My code:

import { RecordScreen } from 'react-native-record-screen';

export default function Screenrecorder({ navigation }) {

const startrecording = () => {
    RecordScreen.startRecording({ mic: false }).catch((error) =>
    console.error(error)
);

return (
    <View >
        <TouchableOpacity
            onPress={startrecording}
            underlayColor='rgba(0, 0, 0, 0)'>
           <Text>Start Recording</Text>
        </TouchableOpacity>
    </View>`

);
}

The error occurs when I press "Start Recording".

Upvotes: 0

Views: 178

Answers (2)

Vimal
Vimal

Reputation: 73

I also face this issue for another developer if this issue has occurred you can resolve it by importing like this as per the document

import RecordScreen from 'react-native-record-screen';

Upvotes: 0

Nooruddin Lakhani
Nooruddin Lakhani

Reputation: 6967

Try adding async in code like

const startrecording = asyn () => {
    await RecordScreen.startRecording({ mic: false }).catch((error) =>
    console.error(error)
);

Upvotes: 0

Related Questions