Coder Social home page Coder Social logo

Comments (14)

azopyros avatar azopyros commented on April 18, 2024 1

@rpereira have you try res.render('index.jsx', data) ?

from express-react-views.

zpao avatar zpao commented on April 18, 2024 1

Going to close out since we don't have a reliable repro. Feel free to comment if you work one out and we can revisit.

from express-react-views.

WinWinHost avatar WinWinHost commented on April 18, 2024 1

Encountered the same issue today when upgrading my MERN project.

-Robert Baindourov

from express-react-views.

zpao avatar zpao commented on April 18, 2024

The <!doctype> isn't valid jsx and could be causing a parse issue. Maybe that's just getting swallowed?

from express-react-views.

rpereira avatar rpereira commented on April 18, 2024

Hi @zpao,

I've removed the <!doctype> and the same problem persists.

from express-react-views.

zpao avatar zpao commented on April 18, 2024

I tried to reproduce this and I'm having trouble doing so reliably. I did get it to happen once but not a 2nd time (I did have some babel preset issues though, will need to look into that more). The only way I can repro reliably is if I name the file index.js instead of index.jsx.

If you had a reproducible test app I could look at, that might be helpful.

from express-react-views.

zpao avatar zpao commented on April 18, 2024

@ruiafonsopereira are you still having issues?

from express-react-views.

rpereira avatar rpereira commented on April 18, 2024

Hi @zpao,

I had to drop that experiment because I got stuck. If you give me a few days to try and set up a reproducible test app I can get back to you. If you prefer to close this issue in the meantime, go ahead and I'll let you know if the problem persists.
Thanks.

from express-react-views.

adrianiskandar avatar adrianiskandar commented on April 18, 2024

I have the same issue, is not finding the views and looks like the settings object in options is undefined:

TypeError: Cannot read property 'views' of undefined
at View.renderFile as engine
at View.render (/projects/modul/node_modules/express/lib/view.js:126:8)
at tryRender (/projects/modul/node_modules/express/lib/application.js:639:10)
at EventEmitter.render (/projects/modul/node_modules/express/lib/application.js:591:3)
at ServerResponse.render (/projects/modul/node_modules/express/lib/response.js:960:7)
at /projects/modul/core/routes/errors.js:27:11
at Layer.handle_error (/projects/modul/node_modules/express/lib/router/layer.js:71:5)
at trim_prefix (/projects/modul/node_modules/express/lib/router/index.js:310:13)
at /projects/modul/node_modules/express/lib/router/index.js:280:7
at Function.process_params (/projects/modul/node_modules/express/lib/router/index.js:330:12)

from express-react-views.

azopyros avatar azopyros commented on April 18, 2024

I had it because my index was name index.js instead of index.jsx.

Because I don't want to have .jsx I did this :

    app.set('view engine', 'js')
    app.engine('js', expressReactViews.createEngine({})

from express-react-views.

rpereira avatar rpereira commented on April 18, 2024

Hi @azopyros. To be honest, I don't remember given it was last year.

from express-react-views.

anoushk1234 avatar anoushk1234 commented on April 18, 2024

Encountered the same issue today when upgrading my MERN project.

-Robert Baindourov

Same here

from express-react-views.

asbjornu avatar asbjornu commented on April 18, 2024

I have the same issue. When I move the views directory to the root, the views are resolved successfully, but when I move views into a subfolder, view resolution stops working with the same error message as experienced by @rpereira.

Infact, removing the entire app.set('views', …) statement makes no difference; the views directory only works when it's situated at the root.

@azopyros:

@rpereira have you try res.render('index.jsx', data) ?

Adding .jsx to the view name makes no difference to me. It seems like the React view engine completely ignores the path set with app.set('views', …).

from express-react-views.

carlos-dubon avatar carlos-dubon commented on April 18, 2024

For anyone trying to use this with TypeScript just use express-tsx-views instead.

express-tsx-views

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.