Home > OS >  There is an issue in react-native-paper SegmentedButtons
There is an issue in react-native-paper SegmentedButtons

Time:01-11

I am using react-native-paper for SegmentedButtons this is the website link of react-native-paper.

react-native-paper

I just copy and paste all the code in my Project but It gives me this error

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports

when I remove the code of segmentButton then it works fine but when add the code in my project it always gives me this error. when I run this code in Expo snack then it didn't gives any kind of error and runs fine I just cop

Expo snack Link

my Code

    import {SegmentedButtons} from 'react-native-paper';
    
      const [value, setValue] = useState('');
    
return (
     <SafeAreaView>
            <SegmentedButtons
               value={value}
    onValueChange={setValue}
              buttons={[
                {
                  value: 'walk',
                  label: 'Walking',
                },
                {
                  value: 'train',
                  label: 'Transit',
                },
                {
                  value: 'drive',
                  label: 'Driving',
                },
              ]}>
    </SegmentedButtons>
          </SafeAreaView>
    )

CodePudding user response:

I think you need to set up icons https://callstack.github.io/react-native-paper/icons.html especially https://github.com/oblador/react-native-vector-icons because paper uses it.

CodePudding user response:

You can use this library for Segment buttons in React native if react-native-paper segment buttons are not working Link

  • Related