alibaba / fish-redux

An assembled flutter application framework.
https://github.com/alibaba/fish-redux
Apache License 2.0
7.33k stars 843 forks source link

TextField里onChange出现循环 #436

Closed Bedroome closed 5 years ago

Bedroome commented 5 years ago

在使用的时候出现死循环

view.dart

TextField(
      onChanged: (r) {
         dispatch(TestActionCreator.updateCode(r));
      }
)
reducer.dart

Reducer<TestState> buildReducer() {
  return asReducer(
    <Object, Reducer<TestState>>{
      TestAction.updateCode: updateCode
    }
  );
}

TestState updateCode(TestState state, Action action) {
  String text = action.payload ?? '';

  return state.clone()
    ..controller.text = text;
屏幕快照 2019-08-16 下午4 40 38

打字慢的情况未出现问题, 如果连续快速输入 出现循环, 一直不停