Mithril.js: Uncaught TypeError: m.prop is not a function

Created on 18 Oct 2017  路  2Comments  路  Source: MithrilJS/mithril.js

I have the following code snippet --

const clearButton = {
  view: (_, args) => 
    m('button', { onclick: args.clickAction }, 'Clear')
}

const helloWorld = {
  view: (_, args) => [
    m('h1', 'Hello World'),
    m(clearButton, { clickAction: () => args.model('')}),
    ' ',
    m('input', {
      value: args.model(),
      oninput: e => args.model(e.target.value)
    }),
    ' You said: ' + args.model(),
    m('ul', args.model().split('').map(c => m('li', c)))
  ]
}

m.mount(document.body, m(helloWorld, {
  model: m.prop('')
}));

I get the error as m.prop() is not a function. I have imported mithril from a CDN --

<body>
    <script src="https://unpkg.com/[email protected]/mithril.js"></script>
    <script type="text/javascript" src="yousaid.js"></script>
</body>

Most helpful comment

m.prop was default on the old 0.2 version... look at the migration docs...
https://github.com/MithrilJS/mithril.js/blob/next/docs/change-log.md#migrating-from-v02x
basically you should use the mithril/stream in 1.*

All 2 comments

m.prop was default on the old 0.2 version... look at the migration docs...
https://github.com/MithrilJS/mithril.js/blob/next/docs/change-log.md#migrating-from-v02x
basically you should use the mithril/stream in 1.*

@griebd Thanks. Am new to this coming from Angular 2 which is on the heavier side.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

barneycarroll picture barneycarroll  路  3Comments

hadihammurabi picture hadihammurabi  路  4Comments

simov picture simov  路  4Comments

omenking picture omenking  路  3Comments

volnei picture volnei  路  3Comments