• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

miaoxing / mxjs-a-table / 9662801471

25 Jun 2024 12:50PM UTC coverage: 50.0% (+0.7%) from 49.333%
9662801471

push

github

twinh
feat(a-table): 加载数据后才显示表格

11 of 25 branches covered (44.0%)

Branch coverage included in aggregate %.

3 of 3 new or added lines in 1 file covered. (100.0%)

12 existing lines in 2 files now uncovered.

31 of 59 relevant lines covered (52.54%)

4.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

12.5
/TableProvider.js
1
import * as React from 'react';
2
import PropTypes from 'prop-types';
3
import deepMerge from 'deepmerge';
4

5
export const TableContext = React.createContext({});
4✔
6
const useTable = () => React.useContext(TableContext);
16✔
7

8
export default class TableProvider extends React.Component {
9
  static propTypes = {
4✔
10
    render: PropTypes.func,
11
    children: PropTypes.node,
12
  };
13

14
  constructor(props) {
15
    super(props);
×
16

17
    this.state = {
×
18
      search: {},
19
      handleSearch: this.handleSearch,
20
      /**
21
       * @experimental
22
       */
23
      addSearch: this.addSearch,
24
      reload: this.reload,
25
      sort: {},
26
    };
27
  }
28

29
  handleSearch = (search) => {
×
30
    this.setState({search: search}, this.state.reload);
×
31
  };
32

33
  addSearch = (search) => {
×
34
    this.setState({search: deepMerge(this.state.search, search)});
×
35
  };
36

37
  reload = () => {
×
38
  };
39

40
  getContent() {
41
    const {children, render} = this.props;
×
42
    if (render) {
×
43
      return render(this.state);
×
44
    }
45
    if (typeof children === 'function') {
×
46
      return children(this.state);
×
47
    }
48
    return children;
×
49
  }
50

51
  render() {
52
    return <TableContext.Provider value={this.state}>{this.getContent()}</TableContext.Provider>;
×
53
  }
54
}
55

56
function withTable(Component) {
UNCOV
57
  return function TableComponent(props) {
×
UNCOV
58
    return (
×
59
      <TableContext.Consumer>
UNCOV
60
        {(table) => <Component table={table} {...props} />}
×
61
      </TableContext.Consumer>
62
    );
63
  };
64
}
65

66
export { withTable, useTable };
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc