React-virtualized: "Rendered cell should include style property for positioning" warning when using HOC

Created on 25 Oct 2018  路  5Comments  路  Source: bvaughn/react-virtualized

If using HOC for a cell being rendered one will get "Rendered cell should include style property for positioning" warnings in console even if style actually set for an inner component. The following example is showing React-Draggable being used together with cell renderer.

        ...
        <Draggable
           key={key}
           ...
           <-- we can't put style here because Draggable component doesn't accept such prop
        >
          <div style={style} ... >
            caption
           </div>
        </Draggable>
        ...

Most helpful comment

Has anyone discovered a work-around for this? Perhaps we could have a data-react-virtualized-no-warning prop that could be used to disable the warning a case-by-case basis?

All 5 comments

Can't find where to put this style to make log shut up:
https://codesandbox.io/s/monr4x9qnx
(I'm putting the style in NodeView.jsx)

Solution:

rowRenderer = ({ key, index, style }) => {
    return (
      <div style={style}>
        <Observer>
          {() => (
            <NodeWithDnD
              key={key}
              index={index}
              node={this.items[index]}
            />
          )}
        </Observer>
      </div>
    );
  };

(now the rowRenderer with MobX works without any warnings from Virtualized and reactively)

It will not work in my case as Draggable HOC must be outer component.

Has anyone discovered a work-around for this? Perhaps we could have a data-react-virtualized-no-warning prop that could be used to disable the warning a case-by-case basis?

I vote for removing this warning. It is so annoying.

Was this page helpful?
0 / 5 - 0 ratings