Comments (8)
I think that's probably fine. So I guess app.js would look like this?
var React = require('react');
var views = require('express-react-views');
app.engine('jsx', views.createEngine(React, options));
Then we would just need to feature/version check to make sure renderToStaticMarkup
exists.
Want to give it a shot?
from express-react-views.
Yep I will npm link
a fork of this module to give and try.
I will push that as a PR if it is successful.
from express-react-views.
Does npm not check the version for you? I don't think you should have to check for renderToStaticMarkup manually.
from express-react-views.
@spicyj I don't think peerDeps are really properly checked, though I could be wrong. I agree it seems silly... If we get the check for free then yea, we shouldn't do it ourselves.
from express-react-views.
Yes, the lack of peerDependency is actually not allowing you to render a component. It returns this error:
Error: Invariant Violation: renderComponentToStaticMarkup(): You must pass a valid ReactComponent.
at invariant (/usr/local/lib/node_modules/express-react-views/node_modules/react/lib/invariant.js:49:15)
at Object.renderComponentToStaticMarkup (/usr/local/lib/node_modules/express-react-views/node_modules/react/lib/ReactServerRendering.js:67:44)
at View.renderFile [as engine] (/usr/local/lib/node_modules/express-react-views/index.js:36:23)
This is because react checks for instanceof ReactDescriptor
(seen here), and since your app
and express-react-views
are using different instances of react it is always false.
This is fixed by setting react as a peer dependency. I have issued PR #4 for this.
from express-react-views.
Hello! I debug a long time, and get the same result as @ekryski . (I hope I read this before :( )
@oncletom , please merge RP #4 to resolve this problem.
from express-react-views.
It got merged. I'll be pushing out 0.5 shortly
from express-react-views.
\o/
from express-react-views.
Related Issues (20)
- onClick event listener not working
- babel-register not updated in release from nine months ago HOT 2
- document is not defined HOT 1
- Feature request: Locals as a context HOT 3
- Error: Cannot find module 'babel-core' HOT 3
- Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3" HOT 3
- If we need a view engine of ‘tsx’.
- Dynamic example is vulnerable to XSS HOT 2
- React component use HOT 1
- Dealing with different file extensions for production HOT 1
- Any plans for webpack support?
- SyntaxError: Unexpected token '<'
- Error: Cannot find module '@babel/plugin-transform-flow-strip-types'
- cannot import bootstrap when using the jsx view engine HOT 4
- Is this reactive? HOT 3
- React Dev Tools Does Not Comprehend React Components HOT 1
- React setState did not rerender the page HOT 4
- add external script file
- How to load javascript with express-react-views HOT 2
- React 17
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from express-react-views.