Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * setDefaultProps
- * @param props
- * @param propDefaults
- *
- * A helper function used to set default values for props generated by SPFX.
- * This allows variables that must not be undefined to be given a default value.
- *
- */
- export function setDefaultProps<I>(props: I, propDefaults: I) {
- const defaults = propDefaults as Object;
- Object.keys(defaults).forEach((property: string) => {
- if (props[property] === undefined) {
- props[property] = defaults[property];
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement