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

addView(View) is not supported in AdapterView #599

Open
shukerullah opened this issue Nov 21, 2024 · 1 comment
Open

addView(View) is not supported in AdapterView #599

shukerullah opened this issue Nov 21, 2024 · 1 comment

Comments

@shukerullah
Copy link

Description

When using the @react-native-picker/picker package in a React Native project, navigating back from a screen containing the Picker component causes the following error on Android:

Error: Exception in HostFunction: java.lang.UnsupportedOperationException: addView(View) is not supported in AdapterView

Steps to Reproduce

  1. Create a React Native app.
  2. Install the @react-native-picker/picker package.
  3. Add a screen with the Picker component inside a View.
  4. Navigate to the screen with the Picker.
  5. Press the back button to navigate away.
  6. Observe the error.

Expected Behavior

The screen should unmount without throwing any errors.

Actual Behavior

An error is thrown when pressing the back button:

Error: Exception in HostFunction: java.lang.UnsupportedOperationException: addView(View) is not supported in AdapterView

Reproduction Code

Weather.tsx:
import React from 'react';
import { View } from 'react-native';
import Picker from '../../components/ui/picker';

const Weather: React.FC = () => {
  return (
    <View>
      <Picker />
    </View>
  );
};

export default Weather;
Picker.tsx:
import { Picker as PickerRN } from '@react-native-picker/picker';
import React from 'react';

const Picker = () => {
  return (
    <PickerRN>
      <PickerRN.Item label="Java" value="java" />
      <PickerRN.Item label="JavaScript" value="js" />
    </PickerRN>
  );
};

export default Picker;

Environment

System:
  OS: macOS 14.1.1
  CPU: (8) arm64 Apple M2
  Memory: 523.48 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 21.5.0
    path: /opt/homebrew/bin/node
  Yarn:
    version: 3.6.4
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.2.4
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2023.12.04.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.18034.62.2411.12071903
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.9
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.1
    wanted: 15.0.1
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.76.2
    wanted: 0.76.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Attachments

screen_recording

@Elhelali
Copy link

I can confirm this issue on my end, seems to not affect functionality too much except if entry and exit are spammed.

To add Context, in my case, the "back" button is

@react-navigation/native
const navigation = useNavigation();
navigation.goBack()

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

2 participants