stormpath-express-react-example
stormpath-express-react-example copied to clipboard
Purpose of the index.js file?
Why do we need this file?
export MasterPage from './MasterPage'
export IndexPage from './IndexPage'
export LoginPage from './LoginPage'
export RegisterPage from './RegisterPage'
export ResetPasswordPage from './ResetPasswordPage'
export VerifyEmailPage from './VerifyEmailPage'
export ProfilePage from './ProfilePage'
export ChangePasswordPage from './ChangePasswordPage'
When each of the, say for example IndexPage has its own
export default class IndexPage extends React.Component { ....
}
Did you figure this out? I don't understand what this file does, but without it things fail.
@micahstartnow @scheung38 without it, you would have to import each Component as such:
import MasterPage from './MasterPage'
import IndexPage from './IndexPage'
import LoginPage from './LoginPage'
import RegisterPage from './RegisterPage'
import ResetPasswordPage from './ResetPasswordPage'
import VerifyEmailPage from './VerifyEmailPage'
import ProfilePage from './ProfilePage'
import ChangePasswordPage from './ChangePasswordPage'
You're exposing each component by adding export default class before the class declaration but the index.js functions as an entry point that groups all of these similar components so you can organize them and export them more neatly. It's really just a preference.