Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. /**
  2. * setDefaultProps
  3. * @param props
  4. * @param propDefaults
  5. *
  6. * A helper function used to set default values for props generated by SPFX.
  7. * This allows variables that must not be undefined to be given a default value.
  8. *
  9. */
  10. export function setDefaultProps<I>(props: I, propDefaults: I) {
  11. const defaults = propDefaults as Object;
  12. Object.keys(defaults).forEach((property: string) => {
  13. if (props[property] === undefined) {
  14. props[property] = defaults[property];
  15. }
  16. });
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement