GeekyAnts / vue-native-website

The website of Vue Native
http://vue-native.io
MIT License
36 stars 53 forks source link

Issues following the docs! #69

Closed PanosTrak closed 4 years ago

PanosTrak commented 4 years ago

I am following the docs and I am on conditional part.

<view>
  <text v-if="seen">Now you see me</text>
  <button :on-press="seen = !seen">Click to Toggle</button>
</view>

when i paste this into my code i get the error of: Invariant Violation: The title prop of a Button must be a string

so i wrote a v-bind:title="something" and set that in the data but then i get the error of console.error: "[Vue warn]: You may have an infinite update loop in a component render function (found in <Anonymous>)"

I do something wrong or the docs are outdated?

RishabhKarnad commented 4 years ago

Actually, this part of the docs is incorrect. We'll update it to reflect the correct code.

Essentially, :on-press and other handlers need to be passed either methods or callbacks.

This should work:

<button :on-press="() => { seen = !seen }">Click to Toggle</button>

A cleaner way might be to create a method toggleSeen:

<button @press="toggleSeen">Click to Toggle</button>
...
methods: {
  toggleSeen() {
    this.seen = !this.seen
  }
},