skip to Main Content

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>
    )

3

Answers


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

    Login or Signup to reply.
  2. Try move the react-native-paper from package.json and install it again .

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search