2

I am learning react native. My index.js file is like below :

import React from 'react';
import { AppRegistry } from 'react-native';
import { Provider } from 'react-redux';
import App from './App';
import configureStore from './src/store/configureStore';

const store = configureStore();

const RNRedux = () => (
    <Provider store={store}>
        <App />
    </Provider>
);

AppRegistry.registerComponent('redux1', () => RNRedux);

Now, my question is : "React" is not used anywhere. So, why am I importing it here ? If I comment it out then I am getting an error "Cant find variable: React". Does react native need it ? If so, then why react native haven't imported it ? Is there any reason behind it ?

I understand that I am importing "react" in my App.js file as I am using Component.

Thank you.

** I have found my answer. I have forgot that I have used JSX in the index.js file and for that I need to import react.

1 Answer 1

3

React includes what’s necessary for the JSX syntax. If you don’t import React, you can’t use JSX.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.