GithubHelp home page GithubHelp logo

Comments (8)

zpao avatar zpao commented on April 28, 2024

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.

thom4parisot avatar thom4parisot commented on April 28, 2024

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.

sophiebits avatar sophiebits commented on April 28, 2024

Does npm not check the version for you? I don't think you should have to check for renderToStaticMarkup manually.

from express-react-views.

zpao avatar zpao commented on April 28, 2024

@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.

ekryski avatar ekryski commented on April 28, 2024

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.

lijunle avatar lijunle commented on April 28, 2024

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.

zpao avatar zpao commented on April 28, 2024

It got merged. I'll be pushing out 0.5 shortly

from express-react-views.

thom4parisot avatar thom4parisot commented on April 28, 2024

\o/

from express-react-views.

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.