withPicker.tsx 721 B

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