Vue Bindings for Redux

Vue Bindings for Redux

Vue2 Redux Vue bindings for for Redux in only 1.06 kB. ⏭

Vue2 Redux

Vue bindings for for Redux in only 1.06 kB. ⏭

Installation
npm install vue2-redux --save
Setup in project
import Vue from "vue";
import { VueRedux } from "vue2-redux";
import App from "./components/App.vue";
/**
 * Your redux store is exported here like
 * so: `export default createStore( combineReducers( ... ) )`.
 */
import Store from "./store";

Vue.use(VueRedux(Store));

new Vue({
  el: "#app",
  render: h => h(App)
});
Using in a component
<template>
  <div id="app">
    <div v-if="!username">Please enter your username</div>
    <div v-else>Your username is: {{ username }}</div>
    <input @keyup="handleUsernameChange" type="text" />
  </div>
</template>

<script>
  import { connect } from 'vue2-redux'
  import { updateUsername } from '../actions/User'

  const component = {
    name: "app-container",
    methods: {
      handleUsernameChange({ target: { value } }) {
        this.updateUsername(value)
      }
    }
  }

  const mapState = state => ({
    username: state.User.username
  })

  const mapDispatch = dispatch => ({
    updateUsername: nextUsername => dispatch(updateUsername(nextUsername))
  })

  export default connect(mapState, mapDispatch)(component)

</script>
Special note

This WILL NOT work if your .babelrc has:

{
  "presets": [["env"], { "modules": false }]
}

This MUST BE changed to:

{
  "presets": [["env"]]
}

Download Details:

Author: mini-eggs

Source Code: https://github.com/mini-eggs/vue2-redux

vue vuejs javascript

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

8 Popular Websites That Use The Vue.JS Framework

In this article, we are going to list out the most popular websites using Vue JS as their frontend framework. Vue JS is one of those elite progressive JavaScript frameworks that has huge demand in the web development industry. Many popular websites are developed using Vue in their frontend development because of its imperative features.

Vue Native is a framework to build cross platform native mobile apps using JavaScript

Vue Native is a framework to build cross platform native mobile apps using JavaScript. It is a wrapper around the APIs of React Native. So, with Vue Native, you can do everything that you can do with React Native. With Vue Native, you get

How to Make a Simple Vue Custom Select Component

In this article, you’ll learn how to build a Vue custom select component that can be easily be styled using your own CSS. In fact, it’s the same component that we use in production on Qvault, and you can see it in action on the playground.

Creating a Custom Tooltip Component in Vue

There are plenty of libraries out there that will have you up and running with a good tooltip solution in minutes. However, if you are like me, you are sick and tired of giant dependency trees that have the distinct possibility of breaking at any time.

Vue ShortKey plugin for Vue.js

Vue-ShortKey - The ultimate shortcut plugin to improve the UX .Vue-ShortKey - plugin for VueJS 2.x accepts shortcuts globaly and in a single listener.