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.

layout sider will render twice on first load

See original GitHub issue

Version

antd 3.1.0 react 16.2.0

Environment

chrome

Reproduction link

Edit n56noj18oj

class MySider extends Component {
  render() {
    console.log('sider')
    return <Sider>Sider</Sider>
  }
}

class App extends Component {
  render() {
    return (
      <Layout>
      <Header>Header</Header>
      <Layout>
        <MySider></MySider>
        <Content>Content</Content>
      </Layout>
      <Footer>Footer</Footer>
    </Layout>



    );
  }
}

Steps to reproduce

When first load, Snippets above will print sider twice

What is expected?

print sider only once

What is actually happening?

When first load, Snippets above will print sider twice

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
jiacai2050commented, Jan 17, 2018

because we register Sider to Layout by adding it to state.

I can’t really understand this. If this action will cause rerender, why can’t implement Sider in other way, which cause no rerender.

For me as an user, rerender is the last thing I want.

7reactions
yesmeckcommented, Jan 17, 2018

use this method to detect Sider ant-layout-has-sider class is added to layout only after rerendering because we register Sider to Layout by adding it to state.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is my react component rendering twice on initial load?
I've tried this out in code sandbox here and sure enough, it did render twice. This is because, in the index.js file, it...
Read more >
React Components rendered twice — any way to fix this?
It fails to automatically detect render side effects as they often can be non-deterministic behavior. To detect side effects the following functions are...
Read more >
ReactDOM – React
render () controls the contents of the container node you pass in. Any existing DOM elements inside are replaced when first called. Later...
Read more >
Prevent Multiple Renders in React - YouTube
When component loads first time, it renders twice because it is logging in console ... Strict Mode does not render any visibble UI...
Read more >
Are my components supposed to render multiple times? - Reddit
You still will be rendering a loading state followed by the actual data in most cases. If you're using server-side rendering, you can...
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