title: react-saga call function on source component
body: <p>I'm pretty unsure how to ask this correctly. (I'm sorry) Basically I want to call the <strong>onError</strong> function in my Component with the Error String when the Saga function got a error. So I can fire up the Snackbar for 5 sec and then hide it again.</p>
  
  <p>But I don't know how exactly I can call this Function from my Saga function. Currently it return the error on the <code>this.state.error</code> State as String. I tried to use <code>componentWillReceiveProps</code> but this doesn't work on the 2nd try when the string is still the same.</p>
  
  <p>To avoid a xyproblem I'll just post the piece of code that I have.</p>
  
  <p>I got the following component:</p>
  
  <pre><code>class RegisterForm extends React.Component {
  
    constructor(props) {
      super(props);
      this.state = {
        email: '',
        username: '',
        password: '',
        SnackbarOpen: false,
      };
    }
    onSubmit = (event) =&gt; {
      event.preventDefault();
      this.props.register(this.state.email, this.state.username, this.state.password);
    }
  
    onError(error) {
      this.setState({SnackbarOpen: true})
      setTimeout(() =&gt; {
        this.setState({SnackbarOpen: false});
      }, 5000);
    }
  
    render(): with &lt;form&gt;
  }
  
  const mapStateToProps = (state) =&gt; ({
    error: state.auth.error,
  });
  
  const mapDispatchToProps = (dispatch) =&gt; ({
    register: (email, username, password) =&gt; {
      dispatch(Actions.register(email, username, password));
    }
  });
  
  export default connect(mapStateToProps, mapDispatchToProps)(RegisterForm);
  </code></pre>
  
  <p>Which call this Redux-Saga Function:</p>
  
  <pre><code>import { Types } from './Actions';
  import CognitoService from './CognitoService';
  
  function* register(action) {
    try {
      const result = yield call(CognitoService.register, action);
      yield put({ type: Types.registrationSuccess, user: result.user });
    } catch(error) {
      yield put({ type: Types.registrationFail, error: error.message });
    }
  }
  
  function* authSaga() {
    yield takeLatest(Types.register, register);
  }
  
  export default authSaga;
  </code></pre>