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

Android: onStateChange does not return 'idle' or 'spinning' #786

Closed
chauncat opened this issue Mar 18, 2024 · 1 comment · Fixed by #797
Closed

Android: onStateChange does not return 'idle' or 'spinning' #786

chauncat opened this issue Mar 18, 2024 · 1 comment · Fixed by #797

Comments

@chauncat
Copy link

chauncat commented Mar 18, 2024

Describe the bug
When newArch is false onStateChange is returning entire event instead of just the string.

When writing the parameter from onStateChange to console log it shows the full event.

        <DatePicker
          ...
          onStateChange={(e) => {
            console.log('event', e);
          }}
event {
	"_dispatchInstances": {
		"_debugHookTypes": null,
		"_debugNeedsRemount": false,
		"_debugOwner": {
			"_debugHookTypes": null,
			"_debugNeedsRemount": false,
			"_debugOwner": [FiberNode],
			"_debugSource": undefined,
			"actualDuration": 0.32708299986552447,
			"actualStartTime": 763915.602665,
			"alternate": [FiberNode],
			"child": [Circular],
			"childLanes": 0,
			"deletions": null,
			"dependencies": null,
			"elementType": [Function DatePickerAndroid],
			"flags": 1,
			"index": 0,
			"key": null,
			"lanes": 0,
			"memoizedProps": [Object],
			"memoizedState": null,
			"mode": 2,
			"pendingProps": [Object],
			"ref": null,
			"return": [FiberNode],
			"selfBaseDuration": 0.2715099999913946,
			"sibling": null,
			"stateNode": [DatePickerAndroid],
			"subtreeFlags": 4,
			"tag": 1,
			"treeBaseDuration": 0.30411399994045496,
			"type": [Function DatePickerAndroid],
			"updateQueue": [Object]
		},
		"_debugSource": undefined,
		"actualDuration": 0.04666699992958456,
		"actualStartTime": 763915.879384,
		"alternate": {
			"_debugHookTypes": null,
			"_debugNeedsRemount": false,
			"_debugOwner": [FiberNode],
			"_debugSource": undefined,
			"actualDuration": 0.10296799999196082,
			"actualStartTime": 764945.181519,
			"alternate": [Circular],
			"child": null,
			"childLanes": 0,
			"deletions": null,
			"dependencies": null,
			"elementType": "RNDatePicker",
			"flags": 4,
			"index": 0,
			"key": null,
			"lanes": 0,
			"memoizedProps": [Object],
			"memoizedState": null,
			"mode": 2,
			"pendingProps": [Object],
			"ref": null,
			"return": [FiberNode],
			"selfBaseDuration": 0.07322900008875877,
			"sibling": null,
			"stateNode": [ReactNativeFiberHostComponent],
			"subtreeFlags": 0,
			"tag": 5,
			"treeBaseDuration": 0.07322900008875877,
			"type": "RNDatePicker",
			"updateQueue": null
		},
		"child": null,
		"childLanes": 0,
		"deletions": null,
		"dependencies": null,
		"elementType": "RNDatePicker",
		"flags": 4,
		"index": 0,
		"key": null,
		"lanes": 0,
		"memoizedProps": {
			"accessibilityLabel": "dateTimePicker",
			"androidVariant": "nativeAndroid",
			"cancelText": "Cancel",
			"confirmText": "Confirm",
			"date": "2024-03-18T19:16:00.000Z",
			"fadeToColor": undefined,
			"id": "0.7786056200089707",
			"is24hourSource": "locale",
			"locale": "en_GB",
			"maximumDate": undefined,
			"minimumDate": undefined,
			"minuteInterval": 1,
			"mode": "time",
			"onChange": [Function anonymous],
			"onDateChange": [Function onDateChange],
			"onStateChange": [Function onStateChange],
			"style": [Array],
			"testID": "dateTimePicker",
			"textColor": undefined,
			"theme": "light",
			"timeZoneOffsetInMinutes": "",
			"timezoneOffsetInMinutes": "",
			"title": "Select time"
		},
		"memoizedState": null,
		"mode": 2,
		"pendingProps": {
			"accessibilityLabel": "dateTimePicker",
			"androidVariant": "nativeAndroid",
			"cancelText": "Cancel",
			"confirmText": "Confirm",
			"date": "2024-03-18T19:16:00.000Z",
			"fadeToColor": undefined,
			"id": "0.7786056200089707",
			"is24hourSource": "locale",
			"locale": "en_GB",
			"maximumDate": undefined,
			"minimumDate": undefined,
			"minuteInterval": 1,
			"mode": "time",
			"onChange": [Function anonymous],
			"onDateChange": [Function onDateChange],
			"onStateChange": [Function onStateChange],
			"style": [Array],
			"testID": "dateTimePicker",
			"textColor": undefined,
			"theme": "light",
			"timeZoneOffsetInMinutes": "",
			"timezoneOffsetInMinutes": "",
			"title": "Select time"
		},
		"ref": null,
		"return": {
			"_debugHookTypes": null,
			"_debugNeedsRemount": false,
			"_debugOwner": [FiberNode],
			"_debugSource": undefined,
			"actualDuration": 0.32708299986552447,
			"actualStartTime": 763915.602665,
			"alternate": [FiberNode],
			"child": [Circular],
			"childLanes": 0,
			"deletions": null,
			"dependencies": null,
			"elementType": [Function DatePickerAndroid],
			"flags": 1,
			"index": 0,
			"key": null,
			"lanes": 0,
			"memoizedProps": [Object],
			"memoizedState": null,
			"mode": 2,
			"pendingProps": [Object],
			"ref": null,
			"return": [FiberNode],
			"selfBaseDuration": 0.2715099999913946,
			"sibling": null,
			"stateNode": [DatePickerAndroid],
			"subtreeFlags": 4,
			"tag": 1,
			"treeBaseDuration": 0.30411399994045496,
			"type": [Function DatePickerAndroid],
			"updateQueue": [Object]
		},
		"selfBaseDuration": 0.03260399994906038,
		"sibling": null,
		"stateNode": {
			"_children": [Array],
			"_internalFiberInstanceHandleDEV": [Circular],
			"_nativeTag": 1219,
			"viewConfig": [Object]
		},
		"subtreeFlags": 0,
		"tag": 5,
		"treeBaseDuration": 0.03260399994906038,
		"type": "RNDatePicker",
		"updateQueue": null
	},
	"_dispatchListeners": [Function onStateChange],
	"_targetInst": {
		"_debugHookTypes": null,
		"_debugNeedsRemount": false,
		"_debugOwner": {
			"_debugHookTypes": null,
			"_debugNeedsRemount": false,
			"_debugOwner": [FiberNode],
			"_debugSource": undefined,
			"actualDuration": 0.32708299986552447,
			"actualStartTime": 763915.602665,
			"alternate": [FiberNode],
			"child": [Circular],
			"childLanes": 0,
			"deletions": null,
			"dependencies": null,
			"elementType": [Function DatePickerAndroid],
			"flags": 1,
			"index": 0,
			"key": null,
			"lanes": 0,
			"memoizedProps": [Object],
			"memoizedState": null,
			"mode": 2,
			"pendingProps": [Object],
			"ref": null,
			"return": [FiberNode],
			"selfBaseDuration": 0.2715099999913946,
			"sibling": null,
			"stateNode": [DatePickerAndroid],
			"subtreeFlags": 4,
			"tag": 1,
			"treeBaseDuration": 0.30411399994045496,
			"type": [Function DatePickerAndroid],
			"updateQueue": [Object]
		},
		"_debugSource": undefined,
		"actualDuration": 0.04666699992958456,
		"actualStartTime": 763915.879384,
		"alternate": {
			"_debugHookTypes": null,
			"_debugNeedsRemount": false,
			"_debugOwner": [FiberNode],
			"_debugSource": undefined,
			"actualDuration": 0.10296799999196082,
			"actualStartTime": 764945.181519,
			"alternate": [Circular],
			"child": null,
			"childLanes": 0,
			"deletions": null,
			"dependencies": null,
			"elementType": "RNDatePicker",
			"flags": 4,
			"index": 0,
			"key": null,
			"lanes": 0,
			"memoizedProps": [Object],
			"memoizedState": null,
			"mode": 2,
			"pendingProps": [Object],
			"ref": null,
			"return": [FiberNode],
			"selfBaseDuration": 0.07322900008875877,
			"sibling": null,
			"stateNode": [ReactNativeFiberHostComponent],
			"subtreeFlags": 0,
			"tag": 5,
			"treeBaseDuration": 0.07322900008875877,
			"type": "RNDatePicker",
			"updateQueue": null
		},
		"child": null,
		"childLanes": 0,
		"deletions": null,
		"dependencies": null,
		"elementType": "RNDatePicker",
		"flags": 4,
		"index": 0,
		"key": null,
		"lanes": 0,
		"memoizedProps": {
			"accessibilityLabel": "dateTimePicker",
			"androidVariant": "nativeAndroid",
			"cancelText": "Cancel",
			"confirmText": "Confirm",
			"date": "2024-03-18T19:16:00.000Z",
			"fadeToColor": undefined,
			"id": "0.7786056200089707",
			"is24hourSource": "locale",
			"locale": "en_GB",
			"maximumDate": undefined,
			"minimumDate": undefined,
			"minuteInterval": 1,
			"mode": "time",
			"onChange": [Function anonymous],
			"onDateChange": [Function onDateChange],
			"onStateChange": [Function onStateChange],
			"style": [Array],
			"testID": "dateTimePicker",
			"textColor": undefined,
			"theme": "light",
			"timeZoneOffsetInMinutes": "",
			"timezoneOffsetInMinutes": "",
			"title": "Select time"
		},
		"memoizedState": null,
		"mode": 2,
		"pendingProps": {
			"accessibilityLabel": "dateTimePicker",
			"androidVariant": "nativeAndroid",
			"cancelText": "Cancel",
			"confirmText": "Confirm",
			"date": "2024-03-18T19:16:00.000Z",
			"fadeToColor": undefined,
			"id": "0.7786056200089707",
			"is24hourSource": "locale",
			"locale": "en_GB",
			"maximumDate": undefined,
			"minimumDate": undefined,
			"minuteInterval": 1,
			"mode": "time",
			"onChange": [Function anonymous],
			"onDateChange": [Function onDateChange],
			"onStateChange": [Function onStateChange],
			"style": [Array],
			"testID": "dateTimePicker",
			"textColor": undefined,
			"theme": "light",
			"timeZoneOffsetInMinutes": "",
			"timezoneOffsetInMinutes": "",
			"title": "Select time"
		},
		"ref": null,
		"return": {
			"_debugHookTypes": null,
			"_debugNeedsRemount": false,
			"_debugOwner": [FiberNode],
			"_debugSource": undefined,
			"actualDuration": 0.32708299986552447,
			"actualStartTime": 763915.602665,
			"alternate": [FiberNode],
			"child": [Circular],
			"childLanes": 0,
			"deletions": null,
			"dependencies": null,
			"elementType": [Function DatePickerAndroid],
			"flags": 1,
			"index": 0,
			"key": null,
			"lanes": 0,
			"memoizedProps": [Object],
			"memoizedState": null,
			"mode": 2,
			"pendingProps": [Object],
			"ref": null,
			"return": [FiberNode],
			"selfBaseDuration": 0.2715099999913946,
			"sibling": null,
			"stateNode": [DatePickerAndroid],
			"subtreeFlags": 4,
			"tag": 1,
			"treeBaseDuration": 0.30411399994045496,
			"type": [Function DatePickerAndroid],
			"updateQueue": [Object]
		},
		"selfBaseDuration": 0.03260399994906038,
		"sibling": null,
		"stateNode": {
			"_children": [Array],
			"_internalFiberInstanceHandleDEV": [Circular],
			"_nativeTag": 1219,
			"viewConfig": [Object]
		},
		"subtreeFlags": 0,
		"tag": 5,
		"treeBaseDuration": 0.03260399994906038,
		"type": "RNDatePicker",
		"updateQueue": null
	},
	"bubbles": undefined,
	"cancelable": undefined,
	"currentTarget": {
		"_children": [],
		"_internalFiberInstanceHandleDEV": {
			"_debugHookTypes": null,
			"_debugNeedsRemount": false,
			"_debugOwner": [FiberNode],
			"_debugSource": undefined,
			"actualDuration": 0.04666699992958456,
			"actualStartTime": 763915.879384,
			"alternate": [FiberNode],
			"child": null,
			"childLanes": 0,
			"deletions": null,
			"dependencies": null,
			"elementType": "RNDatePicker",
			"flags": 4,
			"index": 0,
			"key": null,
			"lanes": 0,
			"memoizedProps": [Object],
			"memoizedState": null,
			"mode": 2,
			"pendingProps": [Object],
			"ref": null,
			"return": [FiberNode],
			"selfBaseDuration": 0.03260399994906038,
			"sibling": null,
			"stateNode": [Circular],
			"subtreeFlags": 0,
			"tag": 5,
			"treeBaseDuration": 0.03260399994906038,
			"type": "RNDatePicker",
			"updateQueue": null
		},
		"_nativeTag": 1219,
		"viewConfig": {
			"Commands": [Object],
			"NativeProps": [Object],
			"bubblingEventTypes": [Object],
			"directEventTypes": [Object],
			"uiViewClassName": "RNDatePicker",
			"validAttributes": [Object]
		}
	},
	"defaultPrevented": undefined,
	"dispatchConfig": {
		"phasedRegistrationNames": {
			"bubbled": "onStateChange"
		}
	},
	"eventPhase": undefined,
	"isDefaultPrevented": [Function functionThatReturnsFalse],
	"isPropagationStopped": [Function functionThatReturnsFalse],
	"isTrusted": undefined,
	"nativeEvent": {
		"id": null,
		"spinnerState": "idle"
	},
	"target": {
		"_children": [],
		"_internalFiberInstanceHandleDEV": {
			"_debugHookTypes": null,
			"_debugNeedsRemount": false,
			"_debugOwner": [FiberNode],
			"_debugSource": undefined,
			"actualDuration": 0.04666699992958456,
			"actualStartTime": 763915.879384,
			"alternate": [FiberNode],
			"child": null,
			"childLanes": 0,
			"deletions": null,
			"dependencies": null,
			"elementType": "RNDatePicker",
			"flags": 4,
			"index": 0,
			"key": null,
			"lanes": 0,
			"memoizedProps": [Object],
			"memoizedState": null,
			"mode": 2,
			"pendingProps": [Object],
			"ref": null,
			"return": [FiberNode],
			"selfBaseDuration": 0.03260399994906038,
			"sibling": null,
			"stateNode": [Circular],
			"subtreeFlags": 0,
			"tag": 5,
			"treeBaseDuration": 0.03260399994906038,
			"type": "RNDatePicker",
			"updateQueue": null
		},
		"_nativeTag": 1219,
		"viewConfig": {
			"Commands": [Object],
			"NativeProps": [Object],
			"bubblingEventTypes": [Object],
			"directEventTypes": [Object],
			"uiViewClassName": "RNDatePicker",
			"validAttributes": [Object]
		}
	},
	"timeStamp": 1710789391214,
	"type": undefined
}

Expected behavior
A clear and concise description of what you expected to happen.
Expected the parameter to be return spinning or idle

To Reproduce
Add example code that reproduces the behavior.

export default class App extends Component {

  state = { date: new Date() }

  render = () =>
    <DatePicker
      date={this.state.date}
      onStateChange={(e) => {
            console.log('event', e);
          }
    />
}

Smartphone (please complete the following information):

  • OS: [Android]
  • React Native version [e.g. 0.72.4 thru 0.72.12]
  • react-native-date-picker version 4.4.1 and 4.4.2
@chauncat chauncat changed the title onStateChange does not return 'idle' or 'spinning' Android: onStateChange does not return 'idle' or 'spinning' Mar 18, 2024
@henninghall
Copy link
Owner

Thanks for reporting this. It is fixed in version 5.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants