withPicker.tsx 808 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import React, { Component } from 'react';
  2. export interface IProps {}
  3. // export interface User {
  4. // id: number;
  5. // name: string;
  6. // login: string;
  7. // email: string;
  8. // }
  9. export default function withPicker(WrappedComponent) {
  10. return class WithPicker extends Component<IProps, any> {
  11. constructor(props) {
  12. super(props);
  13. this.toggleLoading = this.toggleLoading.bind(this);
  14. this.state = {
  15. multi: false,
  16. isLoading: false,
  17. };
  18. }
  19. toggleLoading(isLoading) {
  20. this.setState(prevState => {
  21. return {
  22. ...prevState,
  23. isLoading: isLoading,
  24. };
  25. });
  26. }
  27. render() {
  28. return <WrappedComponent toggleLoading={this.toggleLoading} isLoading={this.state.isLoading} {...this.props} />;
  29. }
  30. };
  31. }