withPicker.tsx 860 B

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