You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working with typescript and webpack. Any component wrapped in WDYR will not refresh.
I did notice if you wrap a component whyDidYouRender it will reload.
importReactfrom'react';// will workconstSomeComponent=()=>(<div>
Hello
</div>)SomeComponent.whyDidYouRender=trueconstSomeComponentWrap: React.FC=(props)=>(<SomeComponent{...props}/>)exportdefaultSomeComponentWrap;
...
// will not workconstSomeComponent=()=>(<div>
Hello
</div>)SomeComponent.whyDidYouRender=trueexportdefaultSomeComponent;
constReactRefreshWebpackPlugin=require('@pmmmwh/react-refresh-webpack-plugin');constDEV_MODE=process.env.NODE_ENV!=='production'constplugins=[];if(DEV_MODE){plugins.push(newReactRefreshWebpackPlugin());}module.exports={mode: DEV_MODE ? 'development' : 'production',module: {rules: [{test: /\.(js|ts|tsx)$/,exclude: /node_module/,use: [{loader: 'babel-loader',options: {cacheDirectory: true,babelrc: false,presets: [["@babel/preset-env",{targets: {browsers: "last 2 versions"}}// or whatever your project requires],"@babel/preset-typescript",["@babel/preset-react",{runtime: 'automatic',useBuiltIns: true,development: process.env.NODE_ENV==='development',importSource: '@welldone-software/why-did-you-render',}]],plugins: [// plugin-proposal-decorators is only needed if you're using experimental decorators in TypeScript["@babel/plugin-proposal-decorators",{legacy: true}],["@babel/plugin-proposal-class-properties",{loose: true}],["@babel/plugin-proposal-private-methods",{loose: true}],["@babel/plugin-proposal-private-property-in-object",{loose: true}],DEV_MODE&&'react-refresh/babel',].filter(Boolean),},},]},],},
plugins,};
entry.tsx
importReactfrom'react'import{render}from'react-dom';import'./wdyr'.// <= Placement or order doesn't make a difference.importConectedAppfrom'./components/ConectedApp';constApp=(): React.ReactElement=>{const reactComponent =(<React.StrictMode><ErrorBoundary><ConectedApp/></ErrorBoundary></React.StrictMode>);returnreactComponent;};constrenderApp=(): void=>{
const el=document.getElementById('root');render(App(),el);};window.onload=()=>renderApp();
I'm working with typescript and webpack. Any component wrapped in WDYR will not refresh.
I did notice if you wrap a component
whyDidYouRender
it will reload.webpack.config.js
entry.tsx
wdyr.ts
These may be related.
#224
#201
The text was updated successfully, but these errors were encountered: