Duplicate react app in react devtools
See original GitHub issueHello,
I need help with this strange behaviour. I was updating webpack 4 to webpack 5 and react-loadable to loadable-components. Now when app is running, React Devtools is showing duplicate app. I have no idea why.
If someone had similar problem and know how to fix it, please, Im searching for solution almost week and something.
Thank you
Edit: this is how we render app on BE side
import * as React from 'react'
import * as cs from 'react-intl/locale-data/cs'
import * as en from 'react-intl/locale-data/en'
import * as sk from 'react-intl/locale-data/sk'
import { ChunkExtractor, ChunkExtractorManager } from '@loadable/server'
import { IntlProvider, addLocaleData } from 'react-intl'
import { Provider, connect } from 'react-redux'
import ReactDOMServer from 'react-dom/server'
import { ReduxStateTypes } from 'src/redux/States'
import Route from 'src/app/share/Route'
import ScrollToTop from 'src/components/common/auxiliary_components/ScrollToTop'
import { StaticRouter } from 'react-router-dom'
import { Store } from 'redux'
import path from 'path'
const localeData = require('locales/data.json')
addLocaleData([...en, ...cs, ...sk])
// Mapping method for ConnectedIntlProvider
const mapStateToProps = (state: ReduxStateTypes.DefaultAppState) => ({
locale: state.app.language,
messages: localeData[state.app.language],
})
// Custom IntlProvider that takes locale and messages from main Redux store
const ConnectedIntlProvider = connect(mapStateToProps)(IntlProvider)
const context = {}
const RenderApp = (
url: string,
store: Store<ReduxStateTypes.DefaultAppState>,
staticMarkup?: boolean,
): [string, string, string, string] => {
const extractor = new ChunkExtractor({ statsFile: path.resolve('./dist/public/client/loadable-stats.json') })
const renderFn = staticMarkup ? ReactDOMServer.renderToStaticMarkup : ReactDOMServer.renderToString
const html = renderFn(
<Provider store={store}>
<ConnectedIntlProvider>
<StaticRouter context={context} location={url}>
<ChunkExtractorManager extractor={extractor}>
<ScrollToTop>
<Route />
</ScrollToTop>
</ChunkExtractorManager>
</StaticRouter>
</ConnectedIntlProvider>
</Provider>,
)
const scriptTags = extractor.getScriptTags()
const linkTags = extractor.getLinkTags()
const styleTags = extractor.getStyleTags()
return [html, scriptTags, linkTags, styleTags]
}
export default RenderApp
<Route />
is component, where is router, switch etc. There are loaded app components, for example:
const LoadableRegister = loadable(() => import(/* webpackChunkName: 'register-container' */ 'src/components/login/RegisterContainer'))
and here are 2 scripts from package.json, which we use to run app
"dev:client": "webpack serve --config config/dev.client.webpack.js --progress --color",
"dev:server": "npm run build:css && webpack --config config/dev.server.webpack.js --progress --color --watch",
Issue Analytics
- State:
- Created 3 years ago
- Comments:13
Top Results From Across the Web
React console.log showing duplicate results in Dev Tools
Why does React show duplicate console.log? I found that to remove StrictMode from index.js. but there was no such problem before and why...
Read more >Introducing the New React DevTools
We are excited to announce a new release of the React Developer Tools, available today in Chrome, Firefox, and (Chromium) Edge!
Read more >react-devtools - npm
Run yarn start in packages/react-devtools; Refresh the app after it has recompiled a change; For React Native, copy react-devtools-core to its ...
Read more >Debug React applications with React DevTools
To start the React app server, run the npm start command in the root folder of your project. Open your browser to localhost:3000...
Read more >How to copy props in react dev tools
How to copy props in react dev tools · Open the ReactDevTools in Browser · Select the component that contains the props, in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m just guessing here, but why do you point to the script bundle directly on your html string?
I thought loadable took care of everything with the scriptTags variable
yes, Im closing now