🚀 Feature
Add a second parameter callback to the updateProps function, such that it looks like:
Navigation.updateProps(props, callback).
This is to make updateProps similar to React's setState(newState, callback). The second argument is a callback that is executed once setState is completed and the component is re-rendered.
Internally, updateProps calls setState, so it's just a matter of passing that callback around.
Yes
Motivation
To make updateProps similar to React's setState.
How to implement.
I digged in through the code and I believe it's just a matter of making these changes. (I am not familiar with Typescript syntax, but you'll get the idea)
On /lib/src/Navigation.ts line 191:
public updateProps(componentId: string, props: object, callback) { // add callback parameter
this.commands.updateProps(componentId, props, callback); // pass callback
}
On /lib/src/commands/Commands.ts line 82
public updateProps(componentId: string, props: object, callback) { // add callback parameter
this.store.updateProps(componentId, props, callback); // pass callback
this.commandsObserver.notify(CommandName.UpdateProps, { componentId, props });
}
On /lib/src/components/Store.ts line 12:
updateProps(componentId: string, props: any, callback) { // add callback parameter
this.mergeNewPropsForId(componentId, props);
const component = this.componentsInstancesById[componentId];
if (component) {
this.componentsInstancesById[componentId].setProps(props, callback); //pass callback
}
}
On /lib/src/components/ComponentWrapper.tsx line 52
public setProps(newProps: any, callback) { // add callback parameter
this.setState((prevState) => ({
allProps: {
...prevState.allProps,
...newProps,
},
}), callback); // pass callback
}
I could have done a pull request, but I don't have that much experience in Typescript or creating unit tests, so it would probably have been rejected.
🚀 Feature
Add a second parameter
callbackto theupdatePropsfunction, such that it looks like:Navigation.updateProps(props, callback).This is to make
updatePropssimilar to React'ssetState(newState, callback). The second argument is a callback that is executed oncesetStateis completed and the component is re-rendered.Internally,
updatePropscallssetState, so it's just a matter of passing that callback around.Have you read the Contributing Guidelines on issues?
Yes
Motivation
To make
updatePropssimilar to React'ssetState.How to implement.
I digged in through the code and I believe it's just a matter of making these changes. (I am not familiar with Typescript syntax, but you'll get the idea)
On
/lib/src/Navigation.tsline 191:On
/lib/src/commands/Commands.tsline 82On
/lib/src/components/Store.tsline 12:On
/lib/src/components/ComponentWrapper.tsxline 52I could have done a pull request, but I don't have that much experience in Typescript or creating unit tests, so it would probably have been rejected.