Closed kindslayer closed 4 years ago
for example, in my react component, I want to use a custom class to handle Http errors, And I can't pass the translate method to this class.
class ForgetPassword extends Component { handleSubmitForm = async event => { event.preventDefault(); await Http.post('v1/reset-password', getToken()) .catch(response => { new HttpErrors(response); }) }; render() { Lab lab lab . } } export default ForgetPassword;
and here is my class
import _ from "lodash"; import NativeToast from "components/Toast/NativeToast"; class HttpErrors { constructor({response}) { this.error = ''; this.response = response; } handleError = () => { switch (this.response.status) { case 404: this.error = translate('errors.404'); break; } this.makeNativeToast(); }; makeNativeToast() { NativeToast({message: this.error, type: 'error'}); } } export default HttpErrors;
PR already openned : https://github.com/rmdort/react-redux-multilingual/pull/20
Thanks. Sorry. Will merge and publish in a few hours
Done. Thank you
for example, in my react component, I want to use a custom class to handle Http errors, And I can't pass the translate method to this class.
and here is my class