question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

9.19 throws setState(...): You passed an undefined or null state object; instead, use forceUpdate()

See original GitHub issue

Upgrading to 9.19 started throwing a React warning with React 15.6:

Warning: setState(...): You passed an undefined or null state object; instead, use forceUpdate()

I’m using it like this:

import AutoSizer from 'react-virtualized/dist/commonjs/AutoSizer'
import List from 'react-virtualized/dist/commonjs/List'

@observer
export class FeatureList extends React.Component {
  rowRenderer({ key, index, style }) {
    return <FeatureListItem key={key} style={style} feature={featureStore.featureArray[index]} />
  }

  render() {
    if (!mapUIStore.ready) return null

    return (
      <ul id="panel-items-list">
        <AutoSizer>
          {({ height, width }) => (
            <Observer>
              {() => (
                <List
                  width={width}
                  height={height}
                  rowCount={featureStore.count}
                  rowHeight={31}
                  rowRenderer={this.rowRenderer}
                  scrollToIndex={mapUIStore.scrollToIndex}
                />
              )}
            </Observer>
          )}
        </AutoSizer>
      </ul>
    )
  }
}

The warning happens when scrollToIndex is updated.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
TrySoundcommented, May 24, 2018

Yep this is a breaking change. Try to fix it. We will return null in v10.

0reactions
wuweiweiwucommented, May 25, 2018

Gotcha

Read more comments on GitHub >

github_iconTop Results From Across the Web

React setState(null) and force update - Stack Overflow
Do consider working around the need to imperatively force a state update where possible. function useForceUpdate() { const [i, setI] = React.
Read more >
null vs. undefined: Can I use only one? | by OOO - Medium
At first, I used both because they have different definition · undefined — a non-value that you don't explicitly assign. · null —...
Read more >
react-virtualized | Yarn - Package Manager
Grid and Collection components can be forcefully re-rendered using forceUpdate . For Table and List , you'll need to call forceUpdateGrid to ensure...
Read more >
How to work with React the right way to avoid some common ...
Warning: Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, but it indicates a memory leak in your application....
Read more >
Team:Austin LASA/team team members2.html - iGEM 2018
"undefined" && DEBUG) {\n\t\tif (typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found