Coder Social home page Coder Social logo

Comments (7)

terrysahaidak avatar terrysahaidak commented on August 27, 2024

Hey @moschap, thank for the kind words.

import GitterMobile from './app' is just the short of import GitterMobile from './app/index.js'.
You can check the index.js file.

from gittermobile.

moschap avatar moschap commented on August 27, 2024

Thanks @terrysahaidak ,
I guessed as much that was what the intent was, but my confusion is that in the file /app/index.js there is only this line of export, export default Root.

Sorry again if i am asking as obvious question but where is the GitterMobile derived from? or if there are links that you can refer me to, to catch up on the pattern of import.

from gittermobile.

terrysahaidak avatar terrysahaidak commented on August 27, 2024

As you can see, it's not just export default Root

class Root extends Component {
  render() {
    return (
      <Provider store={store}>
        <View style={{flex: 1}}>
          <App />
        </View>
      </Provider>
    )
  }
}

export default Root

It exports Component named Root I defined above.
I could also write export default class Root extends Component { }.
It all is just a new module syntax, with old one I have to write:
module.exports = Root.

from gittermobile.

moschap avatar moschap commented on August 27, 2024

Yes that is correct. Sorry i missed out that part of the code in my earlier question. I understand that part actually.
The part that is confusing me is the GitterMobile in the import statement. I would have assumed that based on the code above the import from index.android.js file would have been import Root from './app'

from gittermobile.

terrysahaidak avatar terrysahaidak commented on August 27, 2024

Yeah, but it default export, not named, so I can name the module var whatever I want:

// foo.js
const foo = { }
export default foo

// bar.js
const bar = { }
export bar

// baz.js
import whatEverIwant from './foo' // const someVar = require('./foo')
import {bar} from './bar' // const bar = require('./bar').bar or const {bar} = require('./bar')

So I named my root component in the entry file as GitterMobile for better semantic :)

from gittermobile.

moschap avatar moschap commented on August 27, 2024

@terrysahaidak ,

Oh now i understand. Thanks a bunch for the clarification, it all makes sense now.

from gittermobile.

terrysahaidak avatar terrysahaidak commented on August 27, 2024

I glad I could help you, @moschap :)

from gittermobile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.