Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <Component propOne={this.props.one} propTwo={this.props.two}>
  2. {this.props.children}
  3. </Component>
  4.  
  5. <Component propOne={this.props.one} propTwo={this.props.two} {...this.props} >
  6. {this.props.children}
  7. </Component>
  8.  
  9. const {propOne, propTwo, ...leftOver} = this.props;
  10. // `leftOver` contains everything except `propOne` and `propTwo`
  11.  
  12. const {propOne, propTwo, children, ...props} = this.props;
  13. <Component propOne={propOne} propTwo={propTwo} {...props}>
  14. {children}
  15. </Component>
  16.  
  17. function without(props, keys) {
  18. return Object.keys(props)
  19. .filter((key) => keys.indexOf(key) !== -1)
  20. .reduce((retVal, key) => {
  21. retVal[key] = props[key];
  22. }, {});
  23. }
  24.  
  25. <Component propOne={this.props.one} propTwo={this.props.two} {...without(this.props, ['one', 'two'])} >
  26. {this.props.children}
  27. </Component>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement