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.

Components are mounted twice

See original GitHub issue

Version

  • react-native-router-flux v4.0.6
  • react v16.6.1
  • react-native v0.57.5
  • ios 12.x

Expected behaviour

Navigate back to a component and navigate back again. Didmount should be executed once.

Actual behaviour

Navigate to the component again immediately after a component back , it should not cause the component to be mounted twice .

Steps to reproduce

Navigate from “home” to ”productList“

          <Router style={styles.container}>
            <Modal key='modal' hideNavBar>
              <Stack key='root'>
                <Tabs key='tabs'
                      initial
                      hideNavBar>
                  <Scene key='home' tabBarLabel='home' title='home' component={Home}/>
                  <Scene key='profile' tabBarLabel='profile' title='profile' component={Profile}/>
                </Tabs>
                <Stack key='productList' title='productList' component={ProductList}/>
              </Stack>
            </Modal>
          </Router>

Reproducible Demo

The official demo can reproduce this bug

I think this may be because I re-entered the component immediately after exiting the component.

My English is not very good, I hope you can understand, God bless 🙏

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:10

github_iconTop GitHub Comments

4reactions
syntax-ecommented, Sep 10, 2019

Also facing the same issue with “react-native-router-flux”: “4.0.6”

1reaction
chaudhryjunaidcommented, Jan 9, 2019

👍 same here. in fact the initial scene component in a nested stack loaded for the first time is also mounted twice. @aksonov this is deal-breaking for us in using this library. Could you please help?

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Component Mounting Twice - Stack Overflow
I use NextJS and I had reactStrictMode: true, which causes each component to mount twice (on purpose, in dev, for debugging help.. not...
Read more >
React App mounting twice ? : r/react - Reddit
Did you know React 18 mounts a component twice now? It's not a matter of not understanding how effects work, it's just a...
Read more >
App mounting twice in dev mode · Issue #12363 - GitHub
This is caused by rendering the component inside React Strict Mode, to fix this remove the <React.StrictMode> tag from the root of your...
Read more >
React Components rendered twice — any way to fix this?
Let's find out if there is a way to avoid this problem by trying different implementations. A) Functional Component with useState. function App()...
Read more >
Component is mounted twice - why? - Get Help - Vue Forum
I have just discovered this issue in console where most of my components are mounted twice mounted(){ console.log("ComponentName mounted.
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