-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translate function in action creator #53
Comments
The Using your example: export function downloadConfig(config: ConfigState, translate: Translate) {
return function(dispatch: Function): Promise<void> {
return ConfigApi.downloadConfig(config).then(resp => {
fileDownload(JSON.stringify(<ConfigState> resp.data, null, 2), "config.json");
}).catch( error => {
dispatch(showErrorDialog(
'modal.error.connecting',
error.message,
ConfigApi.BASE_URL + JSON_URL));
});
};
} Now your error dialog gets passed the |
That was my first solution as well, but later on I have called the Error dialog with different patterns. It is hard to predict which property of the dialog I will use translate on and which one came from other parts of the application (eg. backend) without translate in the frontend side. dispatch(showErrorDialog(
this.props.translate("new-topology.loading-error-title"),
this.props.translate(`new-topology.${message1}`),
message2 ? this.props.translate(`new-topology.${message2}`) : undefined
)
); It is not that important just bugged me if I can found a neater solution. I had a little time to think about is between two projects. Thanks for your time. |
Most of the time we use the translate function from components. A component gets the translate function as a property from connect.
My problem is that sometimes we must use the translate from an action creator. I wonder if is there better way to access the translate function in an action creator than pass it to each action creator call?
For example:
The text was updated successfully, but these errors were encountered: