Rendering Projects in Expo Go

Has anyone ever noticed an issue with rendering? I’ll try to explain as its pretty complicated…

But I started out using Expo strictly on the browser. I was able to complete one simple React Native app this way.

My next app that I am currently working on I was using the web display and it worked fine until I introduced a component into my app. Ever since it could never render again on the browser.

Then I switched over to working on the iPhone 14 and it was able to render the exact same code no issue.

I continued my development and everything was working fine until I added a <Stack.Navigator> component.

I can still display my but as soon as I try to set it to use the <Stack.Screen /> component the app no longer renders on either the iPhone 14 nor my android that I just got to work.

Any idea what might be going on here?

I have been following along with the tutorial I was watching very closely and the code should be right (as it was in the situation where everything disappeared in the browser that I mentioned earlier).

It’s hard to say. Maybe try npx expo start -c

If that doesn’t help, can you post the code?

Sure.

This is the code that works:

import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";

import ProductsScreen from "../screens/ProductsScreens";
import ProductDetailsScreen from "../screens/ProductDetailsScreen";
import ShoppingCart from "../screens/ShoppingCart";

const Stack = createNativeStackNavigator();

const Navigation = () => {
    return (
        <NavigationContainer>

                <ProductsScreen />


        </NavigationContainer>
    );
};

export default Navigation;

And as soon as I go to this:

import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";

import ProductsScreen from "../screens/ProductsScreens";
import ProductDetailsScreen from "../screens/ProductDetailsScreen";
import ShoppingCart from "../screens/ShoppingCart";

const Stack = createNativeStackNavigator();

const Navigation = () => {
    return (
        <NavigationContainer>
            <Stack.Navigator>
                <Stack.Screen name="Products" component={ProductsScreen} />
            </Stack.Navigator>
                
        </NavigationContainer>
    );
};

export default Navigation;

It breaks. (i.e. nothing shows up. No errors anywhere)

Running npx expo start -c doesn’t seem to do anything.

There’s nothing obviously wrong with the changes.
Could you show the dependencies and devDependencies sections from package.json?

Also, could you explain in more detail what exactly happens when “it breaks”?

Sure thing.

So when the code is working it shows 2 columns of products in a list, which you can scroll up and down and see all the items that were loaded in.

When it “breaks” it shows nothing at all. Blank Screen.

"dependencies": {
    "@expo/webpack-config": "^18.0.1",
    "@react-navigation/native": "^6.1.6",
    "@react-navigation/native-stack": "^6.9.12",
    "expo": "~48.0.18",
    "expo-status-bar": "~1.4.4",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-native": "0.71.8",
    "react-native-safe-area-context": "4.5.0",
    "react-native-screens": "~3.20.0",
    "react-native-web": "~0.18.10"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0"
  },

The code you posted works for me. See here:

I also tried it locally with your dependency versions, since Snack is currently limited to SDK 47.

hmm… maybe it is an issue with pulling the data from the file?

Would you mind giving that a try?

Here is a snippet from products.js:

export default [
  {
    id: "1",
    image: "https://notjustdev-dummy.s3.us-east-2.amazonaws.com/nike/nike1.png",
    images: [
      "https://notjustdev-dummy.s3.us-east-2.amazonaws.com/nike/nike1.png",
      "https://notjustdev-dummy.s3.us-east-2.amazonaws.com/nike/nike1_1.png",
      "https://notjustdev-dummy.s3.us-east-2.amazonaws.com/nike/nike1_2.png",
      "https://notjustdev-dummy.s3.us-east-2.amazonaws.com/nike/nike1_3.png",
      "https://notjustdev-dummy.s3.us-east-2.amazonaws.com/nike/nike1_4.png",
    ],
    name: "Wild Berry",
    price: 160,
    sizes: [39, 40, 41],
    description: `Inspired by the original that debuted in 1985, the Air Jordan 1 Low delivers a clean, classic look that's familiar yet fresh. With an iconic design that blends seamlessly with any fit, these shoes are perfect for taking charge.

Advantages:
- Encapsulated Air-Sole unit for lightweight cushioning.
- Genuine leather on the upper for durability and a premium look.
- Solid rubber outsole for greater traction on different types of surfaces.
- Color Shown: Palomino/White/Wild Berry
- Model: 553558-215
- Proven efficacy

A timeless rubber sole combines with a soft sockliner and encapsulated Nike Air cushioning for all-day comfort. The rubber outsole offers durable traction on a variety of surfaces.`,
  },
  {
    id: "2",
    image: "https://notjustdev-dummy.s3.us-east-2.amazonaws.com/nike/nike2.png",
    images: [
      "https://notjustdev-dummy.s3.us-east-2.amazonaws.com/nike/nike2.png",
      "https://notjustdev-dummy.s3.us-east-2.amazonaws.com/nike/nike2_1.png",
      "https://notjustdev-dummy.s3.us-east-2.amazonaws.com/nike/nike2_2.png",
      "https://notjustdev-dummy.s3.us-east-2.amazonaws.com/nike/nike2_3.png",
      "https://notjustdev-dummy.s3.us-east-2.amazonaws.com/nike/nike2_4.png",
    ],
    name: "Air Force 1",
    price: 169,
    sizes: [39, 40, 41, 42, 43],
    description: `Inspired by the original that debuted in 1985, the Air Jordan 1 Low delivers a clean, classic look that's familiar yet fresh. With an iconic design that blends seamlessly with any fit, these shoes are perfect for taking charge.

Advantages:
- Encapsulated Air-Sole unit for lightweight cushioning.
- Genuine leather on the upper for durability and a premium look.
- Solid rubber outsole for greater traction on different types of surfaces.
- Color Shown: Palomino/White/Wild Berry
- Model: 553558-215
- Proven efficacy

A timeless rubber sole combines with a soft sockliner and encapsulated Nike Air cushioning for all-day comfort. The rubber outsole offers durable traction on a variety of surfaces.`,
  },
];

and here is the ProductsScreen:

import { StyleSheet, Text, View, Image, FlatList } from 'react-native';
import products from '../data/products';

const ProductsScreen = () => {
    return (
        <FlatList
        data={products}
        renderItem={({ item }) => (
          <View style={styles.itemContainer}>
            <Image source={{ uri: item.image}} style={styles.image} />
          </View>
        )}
        numColumns={2}
      />
    )
}

const styles = StyleSheet.create({
    itemContainer: {
      width: "50%",
      padding: 1,
    },
    image: {
      width: "100%", 
      aspectRatio: 1,
    },
  });

  export default ProductsScreen;

and here is the app.js:

import { StatusBar } from 'expo-status-bar';
import { StyleSheet, View} from 'react-native';
import Navigation from './src/components/navigation';

export default function App() {
  return (
    <View style={styles.container}>
      <Navigation />

      <StatusBar style="auto" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

I figured it out!

The issue is here:

<View style={styles.container}>
      <Navigation />

      <StatusBar style="auto" />
    </View>

If we take the Navigation component out of the view it will work. Thanks for you help @wodin I really appreciate it

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.