简体   繁体   中英

Picker in React-native

Just started learning React-native. I'm getting stuck on the picker component. Picker not working on react-native": "0.68.2

I installed it --> npm i @react-native-picker/picker Imported --> import {Picker} from '@react-native-picker/picker';

But still getting error message @react-native-picker/picker could not be found within the project or in these directories: node_modules ..\node_modules

Tried a simple program to list languages, not working!

class testingPicker extends Component {

  state = {
    language:'a'
  }

  render(){
    return(
      <View>
        <Picker 
          style={{width:'100%'}}
          
        >

          {/* Adding options to picker */}
          <Picker.Item label="A" value="a"/>
          <Picker.Item label="B" value="b"/>

        </Picker>
      </View>
    )
  }
}
export default testingPicker;

User "react-native-picker-select" library for picker in react native

For more details Visit

https://blog.logrocket.com/how-to-use-react-native-picker-select/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM