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

Invariant Violation: new NativeEventEmitter() requires a non-null argument. #832

Open
zihaolam opened this issue Jun 13, 2024 · 14 comments
Open

Comments

@zihaolam
Copy link

Describe the bug
ERROR Invariant Violation: new NativeEventEmitter() requires a non-null argument.

This error is located at:
in DatePickerIOS (created by DatePickerWrapper)
in DatePickerWrapper (created by BookSessionModal)
in RCTView
in Unknown (created by BookSessionModal)
in BookSessionModal (created by ModalScreen)
in ModalScreen
in Unknown (created by Route(modal))
in Suspense (created by Route(modal))
in Route (created by Route(modal))
in Route(modal) (created by SceneView)
in StaticContainer
in EnsureSingleNavigator (created by SceneView)
in SceneView (created by SceneView)
in RCTView (created by View)
in View (created by DebugContainer)
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer (created by DebugContainer)
in DebugContainer (created by MaybeNestedStack)
in RNSScreen (created by Animated(Anonymous))
in Animated(Anonymous) (created by InnerScreen)
in Suspender (created by Freeze)
in Suspense (created by Freeze)
in Freeze (created by DelayedFreeze)
in DelayedFreeze (created by InnerScreen)
in InnerScreen (created by Screen)
in Screen (created by MaybeNestedStack)
in Suspender (created by Freeze)
in Suspense (created by Freeze)
in Freeze (created by DelayedFreeze)
in DelayedFreeze (created by ScreenStack)
in RNSScreenStack (created by ScreenStack)
in ScreenStack (created by MaybeNestedStack)
in MaybeNestedStack (created by SceneView)
in RCTView (created by View)
in View (created by SceneView)
in RNSModalScreen (created by Animated(Anonymous))
in Animated(Anonymous) (created by InnerScreen)
in Suspender (created by Freeze)
in Suspense (created by Freeze)
in Freeze (created by DelayedFreeze)

Expected behavior
For the datepicker to render

To Reproduce

import React from "react";
import DatePicker from "react-native-date-picker";
import { View, Text } from "tamagui";

export const BookSessionModal = () => {
	const [isDatePickerOpen, setIsDatePickerOpen] = React.useState(false);
	const [selectedDate, setSelectedDate] = React.useState<Date>(new Date());
	return (
		<View>
			<Text>Book Session</Text>
			<DatePicker
				modal
				open={isDatePickerOpen}
				date={selectedDate}
				onConfirm={(date) => {
					setIsDatePickerOpen(false);
					setSelectedDate(date);
				}}
				onCancel={() => {
					setIsDatePickerOpen(false);
				}}
			/>
		</View>
	);
};

Smartphone (please complete the following information):

  • OS: iOS
  • React Native version 0.74.1
  • react-native-date-picker version ^5.0.4
@andydotdaniel
Copy link

Are you running this in your unit test? I received the same error but only when running unit tests using Jest.

@MarcosJBM
Copy link

MarcosJBM commented Jun 16, 2024

Having the same problem.

  • React Native: 0.68.0

@jvgeee
Copy link

jvgeee commented Jun 17, 2024

@zihaolam @MarcosJBM I was having this issue too, FYI in my experience Invariant Violation: new NativeEventEmitter() bugs in RN seem to be caused by a pods/bundling mismatch between RN and native modules.

For me, updating my packages, updating pods and rebuilding for IOS fixed it:

  • npx expo install --fix (if using expo)
  • npx pod-install (reinstall pods)
  • npx expo run:ios (which re-builds for IOS)

@rocket13011
Copy link

For jest add on setup file jest.mock('react-native-date-picker', () => 'DatePicker');

@btsungu
Copy link

btsungu commented Jun 21, 2024

Any solution for this issue? The date picker works fine on Android but I get this error on iOS. I'm running RN 0.67 and React Native Date Picker ^5.0.4

@colingraydon
Copy link

Going back go version 4.4.0 solved it for my team.

@julekgwa
Copy link

julekgwa commented Jul 6, 2024

on Expo running npx expo prebuild --clean solves the issue.

@fikkatra
Copy link

Going back to v5.0.1 avoids the issue for now

@ryansherby
Copy link

Any progress on this issue?

@ysnbyzli
Copy link

hi, I'm having the same problem too

@btsungu
Copy link

btsungu commented Aug 22, 2024

For me with RN 67 v4.2.2 solved the issue.

@ashirkhan94
Copy link

ashirkhan94 commented Dec 5, 2024

same issue for me any update?

 ERROR  Warning: Invariant Violation: `new NativeEventEmitter()` requires a non-null argument.

This error is located at:
    in DatePickerIOS (created by DatePickerWrapper)

img

@Linda2734
Copy link

Going back to v5.0.1 avoids the issue for now

I tried this, it got rid of the error but now the button is inactive. If anyone has any solutions, I have opened an issue, so you can reply there.

@Linda2734
Copy link

jvgeee

I tried this, it got rid of the error but now the button is inactive. If anyone has any solutions, I have opened an issue, so you can reply there.

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