I followed the tutorial and am trying to run the program however i am getting the error in the console:
Uncaught TypeError: m is not a function
and the code is
`var m = require("mithril")
var UserList = require("./views/UserList")
var UserForm = require("./views/UserForm")
var Layout = require("./views/Layout")
m.route(document.body,"/list",{
"/list": {
render: function () {
return m(Layout, m(UserList))
}
},
"/edit/:id": {
render: function (vnode) {
return m(Layout, m(UserForm, vnode.attrs))
}
},
})
`
the error is given by :
return m(Layout, m(UserList))
Are you using Webpack? If so, try var m = require('mithril').default
thanks it worked
I needed to add
var m = require("mithiril").default to all the js files in order for it to work properly
Cool 馃憤
Yeah, all the requires should be like that.
This will be fixed by #2366 once resolved.
Most helpful comment
Are you using Webpack? If so, try
var m = require('mithril').default