DEV Community

Tyler Smith
Tyler Smith

Posted on

Getting the Community SegmentedControl to Work on iOS in Expo SDK 37

I'm a new React Native developer, and it's been challenging understanding the relationship between React.js, React Native, Expo, the native platforms, and community components.

I wanted to use the React Native Community SegmentedControl in the app I'm building, but I got a mean looking error when I tested on iOS:

Invariant Violation: requireNativeComponent: "RNCSegmentedControl" was not found in the UI Manager.

Yikes.

I'm brand new to mobile development, so the GitHub issue on the SegmentedControl component in Expo was gibberish to me.

The community SegmentedControl component works fine on Android and Web because it's just a copy of the component built with standard React Native parts. As a quick and dirty solution, we can just import this component directly by its full file path.

import SegmentedControl from "@react-native-community/segmented-control/js/SegmentedControl.js";

It's not as smooth as its native counterpart, but it'll get the job done.

I hope this helps. Leave a comment if you know a better way to do this!

Discussion (1)

Collapse
smpetrey profile image
Stephen Petrey

You are a lifesaver. I was pulling my hair out trying to debug that error. Thanks so much!