Given a variable foo='someFunc', I'd like to be able to then call someFunc().
There is a relevant write-up about pure javascript doing exactly this here.
I can't seem to get there with React.
I'm currently doing returnFuncFromString()
:
export default (func: string) => {
switch (func) {
case 'UpAvlToast': return toasts.UpAvlToast();
case 'UpRcvdToast': return toasts.UpRcvdToast();
default:
return null;
}
};
but after a handful of maps, this will become difficult to manage. It is being used to pass constants of message and icon variables to a toastr component. It wouldn't be surprising to have hundreds of preconfigured pairs so I'm hoping for something more dynamic.
There have been similar questions in java, and pure javascript but as there are window
lookup issues involved in the electron bifurcation of the main and render threads they aren't terribly helpful.
via Mark
No comments:
Post a Comment