react-component / react-component/tabs

Maximum update depth exceeded.

Open
#147 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
572
Forks
241
Avg merge
4d 18h
Merged PRs (30d)
4

Description

In the demo below, ScrollableTabBarNode will repeatedly call componentDidUpdate and setState.


export default class App extends PureComponent {
  render() {
    return (
      <Tabs style={{ width: 450 }}>
        <Tabs.TabPane tab="四个汉字" key="1" />
        <Tabs.TabPane tab="汉字" key="2" />
        <Tabs.TabPane tab="四个汉字" key="3" />
        <Tabs.TabPane tab="四个汉字" key="4" />
      </Tabs>
    )
  }
}

.ant-tabs .ant-tabs-bar .ant-tabs-nav-container-scrolling .ant-tabs-nav-scroll .ant-tabs-nav-animated {
  padding: 0 8px;
}

.ant-tabs .ant-tabs-bar .ant-tabs-nav-scroll .ant-tabs-nav {
  padding: 0 16px;
}
bundle.js:15177 Uncaught Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.
    at invariant (bundle.js:15177)
    at scheduleWork (bundle.js:32076)
    at Object.enqueueSetState (bundle.js:26745)
    at ScrollableTabBarNode../node_modules/react/cjs/react.development.js.Component.setState (bundle.js:39646)
    at ScrollableTabBarNode.setNext (bundle.js:13859)
    at ScrollableTabBarNode.setNextPrev (bundle.js:13764)
    at ScrollableTabBarNode.componentDidUpdate (bundle.js:13708)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the demo with ScrollableTabBarNode and the provided CSS, then inspect its componentDidUpdate, setNextPrev, and setNext call path from the stack trace. Done means the example no longer reaches React's maximum update depth error while tab scrolling continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.