jeremy-ww / vue-setstate

:zap: Using React style setState method in Vue, apply to optimize rendering speed of big data

Home Page:https://codesandbox.io/s/7jx3pn4w71

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vue-setState Build Status npm package

Using React style setState method in Vue, Apply to optimize rendering speed of big data

Install

$ npm i vue-setstate -S

CDN: UNPKG | jsDelivr

Usage

import Vue from 'vue'
import setState from 'vue-setstate'

Vue.use(setState)

Then in your component:

<script>
export default {
  state: {
    // your data here
    name: 'tom'
  },

  methods: {
    changeMyName () {
      this.setState({ name: 'mary' })
    },
    changeMyNameWithFunctionalParam () {
      this.setState(({ name }) => ({
        name: `Hi ${name}`
      }))
    }
  }
}
</script>

Warning: state is not reactive!, you must use setState method if you want to change the view.

License

MIT

Copyright (c) 2017-present, Army-U

About

:zap: Using React style setState method in Vue, apply to optimize rendering speed of big data

https://codesandbox.io/s/7jx3pn4w71

License:MIT License


Languages

Language:JavaScript 100.0%