VulcanJS / vulcanjs-cli

The official cli scaffolding tool for VulcanJS
36 stars 9 forks source link

generating new route does not import component #20

Closed saravanabalagi closed 5 years ago

saravanabalagi commented 5 years ago

Created a new package movies and created a module movies and component movies.

Executing vulcan g route movies root / asks for componentName, but it add a route to routes.js without importing the component first which results in

W20181124-22:59:13.033(0)? (STDERR) Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
W20181124-22:59:13.043(0)? (STDERR) Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
W20181124-22:59:13.043(0)? (STDERR)     in Movies
W20181124-22:59:13.044(0)? (STDERR)     in DummyErrorCatcher
W20181124-22:59:13.044(0)? (STDERR)     in div
W20181124-22:59:13.044(0)? (STDERR)     in Layout
W20181124-22:59:13.044(0)? (STDERR)     in div
W20181124-22:59:13.044(0)? (STDERR)     in IntlProvider
W20181124-22:59:13.044(0)? (STDERR)     in App
W20181124-22:59:13.044(0)? (STDERR)     in withCookies(Component)
W20181124-22:59:13.045(0)? (STDERR)     in withApollo(withCookies(Component))
W20181124-22:59:13.045(0)? (STDERR)     in withUpdateUser(withApollo(withCookies(Component)))
W20181124-22:59:13.045(0)? (STDERR)     in withSiteData(withUpdateUser(withApollo(withCookies(Component))))
W20181124-22:59:13.045(0)? (STDERR)     in withCurrentUser(withSiteData(withUpdateUser(withApollo(withCookies(Component)))))
W20181124-22:59:13.045(0)? (STDERR)     in RouterContext
W20181124-22:59:13.045(0)? (STDERR)     in CookiesProvider
W20181124-22:59:13.045(0)? (STDERR)     in QueryRecyclerProvider
W20181124-22:59:13.045(0)? (STDERR)     in ApolloProvider
W20181124-22:59:13.045(0)? (STDERR)     in StyleSheetManager
W20181124-22:59:13.046(0)? (STDERR) Error while server-rendering. date: Sat Nov 24 2018 22:59:13 GMT+0000 (GMT Standard Time) url: /
W20181124-22:59:13.070(0)? (STDERR) { Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
W20181124-22:59:13.071(0)? (STDERR)     at invariant (F:\Projects\js\notez\node_modules\react-dom\cjs\react-dom-server.node.development.js:58:15)
W20181124-22:59:13.071(0)? (STDERR)     at ReactDOMServerRenderer.render (F:\Projects\js\notez\node_modules\react-dom\cjs\react-dom-server.node.development.js:3321:7)
W20181124-22:59:13.071(0)? (STDERR)     at ReactDOMServerRenderer.read (F:\Projects\js\notez\node_modules\react-dom\cjs\react-dom-server.node.development.js:3057:29)
W20181124-22:59:13.071(0)? (STDERR)     at renderToString (F:\Projects\js\notez\node_modules\react-dom\cjs\react-dom-server.node.development.js:3524:27)
W20181124-22:59:13.072(0)? (STDERR)     at generateSSRData (packages/vulcan:routing/lib/server/router.jsx:58:14)
W20181124-22:59:13.072(0)? (STDERR)     at sendSSRHtml (packages/vulcan:routing/lib/server/router.jsx:86:45)
W20181124-22:59:13.072(0)? (STDERR)     at match (packages/vulcan:routing/lib/server/router.jsx:149:11)
W20181124-22:59:13.073(0)? (STDERR)     at F:\Projects\js\notez\node_modules\react-router\lib\match.js:67:5
W20181124-22:59:13.073(0)? (STDERR)     at F:\Projects\js\notez\node_modules\react-router\lib\createTransitionManager.js:108:11
W20181124-22:59:13.074(0)? (STDERR)     at done (F:\Projects\js\notez\node_modules\react-router\lib\AsyncUtils.js:79:19)
W20181124-22:59:13.074(0)? (STDERR)     at F:\Projects\js\notez\node_modules\react-router\lib\AsyncUtils.js:85:7
W20181124-22:59:13.074(0)? (STDERR)     at getComponentsForRoute (F:\Projects\js\notez\node_modules\react-router\lib\getComponents.js:11:5)
W20181124-22:59:13.075(0)? (STDERR)     at F:\Projects\js\notez\node_modules\react-router\lib\getComponents.js:35:5
W20181124-22:59:13.075(0)? (STDERR)     at F:\Projects\js\notez\node_modules\react-router\lib\AsyncUtils.js:84:5
W20181124-22:59:13.075(0)? (STDERR)     at Array.forEach (<anonymous>)
W20181124-22:59:13.075(0)? (STDERR)     at mapAsync (F:\Projects\js\notez\node_modules\react-router\lib\AsyncUtils.js:83:9)
W20181124-22:59:13.076(0)? (STDERR)     at getComponents (F:\Projects\js\notez\node_modules\react-router\lib\getComponents.js:34:28)
W20181124-22:59:13.076(0)? (STDERR)     at finishEnterHooks (F:\Projects\js\notez\node_modules\react-router\lib\createTransitionManager.js:102:35)
W20181124-22:59:13.076(0)? (STDERR)     at runTransitionHooks (F:\Projects\js\notez\node_modules\react-router\lib\TransitionUtils.js:79:7)
W20181124-22:59:13.076(0)? (STDERR)     at runEnterHooks (F:\Projects\js\notez\node_modules\react-router\lib\TransitionUtils.js:112:12)
W20181124-22:59:13.076(0)? (STDERR)     at F:\Projects\js\notez\node_modules\react-router\lib\createTransitionManager.js:95:7
W20181124-22:59:13.077(0)? (STDERR)     at runTransitionHooks (F:\Projects\js\notez\node_modules\react-router\lib\TransitionUtils.js:79:7) name: 'Invariant Violation', framesToPop: 1 }

Fix: Importing the component before adding a route fixes the problem.

eric-burel commented 5 years ago

Hi @saravanabalagi, thanks for the feedback. I could not repro, you probably skipped the component import part (you have to tell the CLI to import the component + allow it to override the components.js file with new data, it's a bit tedious but we can't simplify this)