How to use the @tarojs/redux.connect function in @tarojs/redux

To help you get started, we’ve selected a few @tarojs/redux examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kennylbj / patrick-wechat / src / pages / index / index.js View on Github external
import Taro, { Component } from '@tarojs/taro';
import { connect } from '@tarojs/redux';
import { View } from '@tarojs/components';
import { AtList, AtListItem, AtActivityIndicator } from 'taro-ui'
import { fetchQuestionnaires } from '../../actions/questionnaires';
import './index.scss';

@connect(({ questionnaires }) => ({
  questionnaires: questionnaires.list,
  loading: questionnaires.loading,
}))
class Index extends Component {
  config = {
    navigationBarTitleText: '问卷宝典',
    enablePullDownRefresh: true,
  }

  // auto invoke when share
  onShareAppMessage() {
    return {
      title: '问卷宝典',
      path: '/pages/index/index',
    }
  }
github BinZhiZhu / Taro-v2ex-weapp / src / components / latest-data-list / index.tsx View on Github external
title: string
  },
  replies: string,
  title: string
}


interface apiData {
  data:  Array
}

type commonStyle =  {
  width?: string
}

@connect(
  state=>state
)
class LatestDataList extends Taro.Component{

  componentWillMount(): void {
    showLoading();
    this.getList();
    //监听首页下拉刷新事件
    Taro.eventCenter.on('LATEST_DATA_REFRESH',this.getList)
  }


  componentWillUnmount(): void{
    Taro.eventCenter.off('LATEST_DATA_REFRESH')
  }
github shenqihui / taro_scaffold / src / pages / dva / index.tsx View on Github external
import Taro from '@tarojs/taro';
import { View, Navigator } from '@tarojs/components';
import { connect } from '@tarojs/redux';

import { debugAdd } from '../../utils/debug';

import './index.scss';

@connect((state) => {
  return {
    studentState: state.student,
    studentStateLoading: !!state.loading.models.student,
  };
})
export default class PageComponent extends Taro.Component {
  config = {
    navigationBarTitleText: 'dva 例子',
  }

  constructor(props) {
    super(props);
    debugAdd('dva', this);
    this.state = {};
  }
github webclipper / web-clipper-wxapp / src / pages / recent / index.tsx View on Github external
navigateTo,
  initCreatedDocListRequest,
  createdDocumentPulldownRefreshRequest,
  fetchMoreDocRequest
};

type PageStateProps = ReturnType;
type PageDispatchProps = typeof useActions;
type PageOwnProps = {};
type IProps = PageStateProps & PageDispatchProps & PageOwnProps;
const mapActionToProps = dispatch =>
  bindActionCreators(
    useActions,
    dispatch
  );
@connect(
  mapStateToProps,
  mapActionToProps
)
class Index extends Component {
  config: Config = {
    enablePullDownRefresh: true,
    navigationBarTitleText: '最新',
    backgroundTextStyle: 'dark'
  };

  componentDidMount = () => {
    this.props.initCreatedDocListRequest();
  };

  handleClickNode = documentNode => {
    this.props.navigateTo({
github imageslr / taro-library / src / pages / home / index.jsx View on Github external
import { View } from "@tarojs/components";
import PropTypes from "prop-types";
import { connect } from "@tarojs/redux";
import {
  getNewBooks,
  getHotBooks,
  getRecommendBooks
} from "@store/home/action";
import Panel from "../../components/panel";
import HorizonList from "../../components/horizon-list";
import FakeSearchBar from "../../components/fake-search-bar";
import URL from "../../constants/urls";

import "./index.scss";

@connect(
  ({ home }) => ({
    newBooks: home.newBooks,
    hotBooks: home.hotBooks,
    recommendBooks: home.recommendBooks
  }),
  {
    dispatchGetNewBooks: getNewBooks,
    dispatchGetHotBooks: getHotBooks,
    dispatchGetRecommendBooks: getRecommendBooks
  }
)
export default class Home extends Component {
  config = {
    navigationBarTitleText: "首页"
  };
github huangzhuangjia / taro-music / src / pages / listDetail / listDetail.tsx View on Github external
main: StoreState.MainState;
  onFetchSongById: (payload: { id: number, restore: boolean }) => any
}
interface ListDetailStates {
  listData: any;
  scrollState: boolean,
  loading: boolean
}
const mapStateToProps = ({ main }) => ({
  main
})
const mapDispatchToProps = ({
  onFetchSongById: fetchSongById
})

@connect(mapStateToProps, mapDispatchToProps)
class ListDetail extends Component {
  static options = {
    addGlobalClass: true
  }
  constructor() {
    super(...arguments)
    this.state = {
      listData: {},
      scrollState: false,
      loading: true
    }
  }
  componentWillPreload(params) {
    return getPlayList({
      id: params.id
    })
github qit-team / taro-yanxuan / src / pages / user-login-email / user-login-email.js View on Github external
import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image } from '@tarojs/components'
import md5 from 'blueimp-md5'
import { connect } from '@tarojs/redux'
import * as actions from '@actions/user'
import { ButtonItem, InputItem } from '@components'
import { CDN } from '@constants/api'
import './user-login-email.scss'

const LOGO = `${CDN}/6dbf208804386f12aa9e662d82abe563.png`
const EMAIL_SUFFIX = [
  '163.com', '126.com', 'yeah.net', 'vip.163.com', 'vip.126.com'
]

@connect(state => state.user, actions)
class UserLoginEmail extends Component {
  config = {
    navigationBarTitleText: '登录'
  }

  state = {
    username: '',
    password: '',
    isShowSuggest: false,
    loading: false
  }

  componentDidMount() {
    Taro.showToast({
      title: '注意,严选小程序的登录有变动,目前无法正常登录',
      icon: 'none',
github EasyTuan / taro-msparis / src / pages / couponList / index.js View on Github external
import Taro, { Component } from '@tarojs/taro';
import { View, Input, Button, Image } from '@tarojs/components';
import { connect } from '@tarojs/redux';
import './index.scss';

@connect(({ couponList }) => ({
  ...couponList,
}))
class Couponlist extends Component {
  config = {
    navigationBarTitleText: '优惠券',
  };

  componentDidMount = () => {};

  render() {
    return (
github huangzhuangjia / taro-music / src / pages / recommend / recommend.tsx View on Github external
recommendList: any;
  loading: boolean;
  onFetchRecommendList: (payload: { callback: any }) => any;
  onUpdateState: (namespace: string, payload: any) => any;
}

const mapStateToProps = ({ recommend, loading }) => ({
  recommendList: recommend.recommendList,
  loading: loading.effects['recommend/fetchRecommendList']
})
const mapDispatchToProps = ({
  onFetchRecommendList: fetchRecommendList,
  onUpdateState: updateState
})

@connect(mapStateToProps, mapDispatchToProps)
class Recommend extends Component {
  static options = {
    addGlobalClass: true
  }
  constructor() {
    super(...arguments)
  }

  getRecommendList() {
    let recommendList = getCacheData('recommendList')
    if (recommendList && recommendList.length > 0) {
      this.props.onUpdateState('recommend', { recommendList })
    } else {
      this.fetchRecommendList()
    }
  }
github ninghao / w-store-app / src / pages / index / index.js View on Github external
import Taro, { Component } from '@tarojs/taro'
import { View, Button, Text } from '@tarojs/components'
import { connect } from '@tarojs/redux'

import { add, minus, asyncAdd } from '../../actions/counter'

import { AtButton, AtList, AtListItem } from 'taro-ui'

import './index.scss'


@connect(({ counter }) => ({
  counter
}), (dispatch) => ({
  add() {
    dispatch(add())
  },
  dec() {
    dispatch(minus())
  },
  asyncAdd() {
    dispatch(asyncAdd())
  }
}))
class Index extends Component {

  config = {
    navigationBarTitleText: '首页'

@tarojs/redux

Redux for Taro

MIT
Latest version published 4 years ago

Package Health Score

70 / 100
Full package analysis