choojs / choo

:steam_locomotive::train: - sturdy 4kb frontend framework
https://choo.io/
MIT License
6.78k stars 595 forks source link

error app.model is not a function #647

Closed varvarasd closed 6 years ago

varvarasd commented 6 years ago

Hi, there! I just went over to the choodo app tutorial and I'm getting this error as soon as I install budo for my first serve of the app in the browser:

index.js? [sm]:5 Uncaught TypeError: app.model is not a function
    at Object.6.choo (index.js? [sm]:5)
    at s (_prelude.js:1)
    at e (_prelude.js:1)
    at _prelude.js:1 

My index.js looks like so:

const html = require('choo/html')
const app = choo()

app.model({
    state: {
        todos: [
            { title: 'Buy milk' },
            { title: 'Call mum' }
        ]
    }
})

const view = (state, prev, send) => {
    return html`
        <div>
            <h1>Todos</h1>
            <ul>
                ${state.todos.map((todo) => html`<li>${todo.title}</li>`)}
            </ul>
        </div>`
}

app.router([
    ['/', view]
])

const tree = app.start()
document.body.appendChild(tree)

versions:

choo ^6.10.3
npm 5.7.1
budo v11.2.0
browserify v16.1.1
watchify v3.11.0

Much appreciated!

tornqvist commented 6 years ago

Those docs actually reference choo v5. They are called stores now and you add them with the app.use method. See the updated, official, docs here: https://choo.io/docs/stores

varvarasd commented 6 years ago

Right. The solution to this is to go on to the new and updated tutorial .

Thanks!