{"action":"created","issue":{"url":"https://api.github.com/repos/NervJS/taro/issues/594","repository_url":"https://api.github.com/repos/NervJS/taro","labels_url":"https://api.github.com/repos/NervJS/taro/issues/594/labels{/name}","comments_url":"https://api.github.com/repos/NervJS/taro/issues/594/comments","events_url":"https://api.github.com/repos/NervJS/taro/issues/594/events","html_url":"https://github.com/NervJS/taro/issues/594","id":358272028,"node_id":"MDU6SXNzdWUzNTgyNzIwMjg=","number":594,"title":"异步情况下修改redux，无法触发组件render","user":{"login":"Vistey","id":26930562,"node_id":"MDQ6VXNlcjI2OTMwNTYy","avatar_url":"https://avatars1.githubusercontent.com/u/26930562?v=4","gravatar_id":"","url":"https://api.github.com/users/Vistey","html_url":"https://github.com/Vistey","followers_url":"https://api.github.com/users/Vistey/followers","following_url":"https://api.github.com/users/Vistey/following{/other_user}","gists_url":"https://api.github.com/users/Vistey/gists{/gist_id}","starred_url":"https://api.github.com/users/Vistey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vistey/subscriptions","organizations_url":"https://api.github.com/users/Vistey/orgs","repos_url":"https://api.github.com/users/Vistey/repos","events_url":"https://api.github.com/users/Vistey/events{/privacy}","received_events_url":"https://api.github.com/users/Vistey/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"Simbachen","id":1519030,"node_id":"MDQ6VXNlcjE1MTkwMzA=","avatar_url":"https://avatars1.githubusercontent.com/u/1519030?v=4","gravatar_id":"","url":"https://api.github.com/users/Simbachen","html_url":"https://github.com/Simbachen","followers_url":"https://api.github.com/users/Simbachen/followers","following_url":"https://api.github.com/users/Simbachen/following{/other_user}","gists_url":"https://api.github.com/users/Simbachen/gists{/gist_id}","starred_url":"https://api.github.com/users/Simbachen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Simbachen/subscriptions","organizations_url":"https://api.github.com/users/Simbachen/orgs","repos_url":"https://api.github.com/users/Simbachen/repos","events_url":"https://api.github.com/users/Simbachen/events{/privacy}","received_events_url":"https://api.github.com/users/Simbachen/received_events","type":"User","site_admin":false},"assignees":[{"login":"Simbachen","id":1519030,"node_id":"MDQ6VXNlcjE1MTkwMzA=","avatar_url":"https://avatars1.githubusercontent.com/u/1519030?v=4","gravatar_id":"","url":"https://api.github.com/users/Simbachen","html_url":"https://github.com/Simbachen","followers_url":"https://api.github.com/users/Simbachen/followers","following_url":"https://api.github.com/users/Simbachen/following{/other_user}","gists_url":"https://api.github.com/users/Simbachen/gists{/gist_id}","starred_url":"https://api.github.com/users/Simbachen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Simbachen/subscriptions","organizations_url":"https://api.github.com/users/Simbachen/orgs","repos_url":"https://api.github.com/users/Simbachen/repos","events_url":"https://api.github.com/users/Simbachen/events{/privacy}","received_events_url":"https://api.github.com/users/Simbachen/received_events","type":"User","site_admin":false}],"milestone":null,"comments":1,"created_at":"2018-09-08T07:17:02Z","updated_at":"2018-09-10T13:11:51Z","closed_at":null,"author_association":"NONE","body":"**问题描述**\r\n在异步的情况下，触发修改redux的dispatch 能在console里面看到redux-logo变动，也能够在handleAdd（）里面看到this.props.notify 的修改，但却无法触发render\r\n**以下是相关代码**\r\n\r\n```js\r\n// src/page/notify/notify.js\r\nimport Taro, {Component} from '@tarojs/taro'\r\nimport {View} from '@tarojs/components'\r\nimport {connect} from '@tarojs/redux'\r\nimport {getNotifyList} from '../../actions/notify'\r\n\r\n@connect((props) => ({\r\n  ...props,\r\n}))\r\nexport default class Notify extends Component {\r\n  config = {\r\n    navigationBarTitleText: '我的'\r\n  }\r\n\r\n  constructor() {\r\n    super(...arguments)\r\n  }\r\n\r\n  handleAdd = async () => {\r\n    console.log('handleAdd', this.props.notify);\r\n    const {dispatch} = this.props;\r\n    await dispatch(getNotifyList());\r\n  };\r\n\r\n  render() {\r\n    const {notify} = this.props;\r\n    console.log('notify render: ', notify.notifyList);\r\n    return (\r\n      <View>\r\n        <View className='top-tab flex-wrp flex-tab'>\r\n          {\r\n            notify.notifyList.map((item, index) => (\r\n              <View key={index}>\r\n                <View>aaaaa{notify.notifyList[index].title}</View>\r\n              </View>\r\n            ))\r\n          }\r\n        </View>\r\n        <View onClick={this.handleAdd}>++++++</View>\r\n      </View>\r\n    )\r\n  }\r\n}\r\n```\r\n\r\n\r\n```js\r\n// src/actions/notify.js\r\nimport Taro from '@tarojs/taro';\r\n\r\nexport const GET_NOTIFY_LIST = 'GET_NOTIFY_LIST';\r\nexport const REMOVE_NOTIFY_ITEM = 'REMOVE_NOTIFY_ITEM';\r\n\r\nexport function getNotifyList() {\r\n  return async (dispatch) => {\r\n\r\n    return dispatch({\r\n      type: GET_NOTIFY_LIST,\r\n    });\r\n  }\r\n};\r\n```\r\n\r\n```js\r\n// src/reducers/notify.js\r\nimport {\r\n  GET_NOTIFY_LIST,\r\n  REMOVE_NOTIFY_ITEM,\r\n} from '../actions/notify'\r\n\r\nconst initState = {\r\n  notifyList: [{\r\n    title: 'AA',\r\n    remark: 'bbb',\r\n  }, {\r\n    title: 'AA',\r\n    remark: 'bbb',\r\n  }],\r\n};\r\n\r\nexport default function network(state = initState, action) {\r\n\r\n  switch (action.type) {\r\n    case GET_NOTIFY_LIST:\r\n      const {notifyList} = state;\r\n      notifyList.push({\r\n        title: 'AAAA',\r\n        remark: 'bbb',\r\n      });\r\n      return {\r\n        ...state,\r\n        notifyList,\r\n      };\r\n    case REMOVE_NOTIFY_ITEM:\r\n      return {\r\n        ...state,\r\n      };\r\n    default:\r\n      return state\r\n  }\r\n};\r\n```\r\n\r\n**系统信息**\r\n\r\n - 操作系统: [Ubuntu 18.04.01 LTS]\r\n - Taro 版本 [Taro v1.0.0-beta.24]\r\n - Node.js 版本 [v10.8.0]\r\n - npm 版本 [6.2.0]\r\n"},"comment":{"url":"https://api.github.com/repos/NervJS/taro/issues/comments/419906737","html_url":"https://github.com/NervJS/taro/issues/594#issuecomment-419906737","issue_url":"https://api.github.com/repos/NervJS/taro/issues/594","id":419906737,"node_id":"MDEyOklzc3VlQ29tbWVudDQxOTkwNjczNw==","user":{"login":"Vistey","id":26930562,"node_id":"MDQ6VXNlcjI2OTMwNTYy","avatar_url":"https://avatars1.githubusercontent.com/u/26930562?v=4","gravatar_id":"","url":"https://api.github.com/users/Vistey","html_url":"https://github.com/Vistey","followers_url":"https://api.github.com/users/Vistey/followers","following_url":"https://api.github.com/users/Vistey/following{/other_user}","gists_url":"https://api.github.com/users/Vistey/gists{/gist_id}","starred_url":"https://api.github.com/users/Vistey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vistey/subscriptions","organizations_url":"https://api.github.com/users/Vistey/orgs","repos_url":"https://api.github.com/users/Vistey/repos","events_url":"https://api.github.com/users/Vistey/events{/privacy}","received_events_url":"https://api.github.com/users/Vistey/received_events","type":"User","site_admin":false},"created_at":"2018-09-10T13:11:51Z","updated_at":"2018-09-10T13:11:51Z","author_association":"NONE","body":"我尝试将taro更新到了[1.0.0-beta.26]，还是同样的问题，异步更新redux 依然没有办法触发组件的render\r\n\r\n又尝试了在redux执行完成后修改this.state 触发render后redux的修改内容可以正确的渲染在页面上\r\n```js\r\n// src/page/notify/notify.js\r\nhandleAdd = async () => {\r\n    console.log('handleAdd', this.props.notify);\r\n    const {dispatch} = this.props;\r\n    await dispatch(getNotifyList());\r\n    const {a} = this.state;\r\n    this.setState({\r\n      a: !a,\r\n    })\r\n  };\r\n```"}}
{"actor":{"display_login":"Vistey"}}