pupudu / window-table

Windowing Table for React based on React Window
https://window-table.netlify.com/
170 stars 13 forks source link

Trouble with storybook #49

Open Dashue opened 4 years ago

Dashue commented 4 years ago

Trying to use this library in storybook ends up with the following exception:

Cannot update a component (`WindowTable`) while rendering a different component (`AutoSizer`). To locate the bad setState() call inside `AutoSizer`, follow the stack trace as described in https://fb.me/setstate-in-render
    in AutoSizer (created by Measurer)
    in Measurer (created by WindowTable)
    in tr (created by HeaderRowRenderer)
    in thead (created by THead)
    in THead (created by HeaderRowRenderer)
    in HeaderRowRenderer (created by WindowTable)
    in table (created by WindowTable)
    in div (created by WindowTable)
    in WindowTable
    in WindowTable (created by Html5Table)
    in Html5Table
    in Unknown (created by Table)
    in Table (created by storyFn)

In this method

var Measurer = function Measurer(_ref2) {
  var measure = _ref2.measure,
      entity = _ref2.entity,
      debounceWait = _ref2.debounceWait,
      _ref2$innerElementTyp = _ref2.innerElementType,
      innerElementType = _ref2$innerElementTyp === void 0 ? 'div' : _ref2$innerElementTyp;
  var debounced = useMemo(function () {
    return debounce(measure, debounceWait, {
      leading: true
    });
  }, [measure, debounceWait]);
  var dispatch = debounceWait > 0 ? debounced : measure;
  return createElement(AutoSizer, {
    innerElementType: innerElementType
  }, function (_ref3) {
    var height = _ref3.height,
        width = _ref3.width;
    dispatch({
      dimensions: [height, width],
      entity: entity
    });
    return null;
  });
};

On this line:

 dispatch({
      dimensions: [height, width],
      entity: entity
    });
18601673727 commented 4 years ago

same here