0

The same issue was already solved in several posts, but non of them helped me (I'm new to React Native, so possibly there is a solution, but I can't find it)

My code uses route and screen. App.js:

import React from 'react';
import { StackNavigator } from 'react-navigation';

import HomeScreen from './screens/HomeScreen.js';

const App = StackNavigator({
  Home: { screen: HomeScreen }
});

HomeScreen.js:

import React, { Component } from 'react';
import { StyleSheet, Text, View, Button } from 'react-native';

export default class HomeScreen extends Component {
  onPressLearnMore() {

  }

  render() {
    return (
      <View style={styles.container}>
        <Button title="Learn More" onPress={() => this.onPressLearnMore()} />
      </View>
    );
  }
}

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

What is wrong?

The project structure:

enter image description here

2
  • What is your file structure? is App.js in the same directory with the screens directory? Can you post the complete error please? Commented Sep 13, 2017 at 17:45
  • really dumb mistake. I just didn't imported it anywhere Commented Sep 13, 2017 at 17:49

2 Answers 2

2

you must export default App in app.js

Sign up to request clarification or add additional context in comments.

Comments

0

You don't need to define the file type in your import.

Change this import HomeScreen from './screens/HomeScreen.js';

To this import HomeScreen from './screens/HomeScreen';

Hope it helps.

Edit: Just to gather all information in this answer, as suggested in the comments you should also export your App.js

2 Comments

Is there any more code in your App.js? For instance, how are you exporting it?
App.js is not exported anywhere

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.