Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-refresh-webpack-plugin not updating component when wrapped with React.memo. #292

Open
kyukk opened this issue Mar 8, 2024 · 0 comments

Comments

@kyukk
Copy link

kyukk commented Mar 8, 2024

When wrapping component in React.memo its stop to updating, when something changed. Its happens only if component being exported and wrapped in memo.

wdyr.js

import React from "react";

if (process.env.NODE_ENV === 'development') {
  const whyDidYouRender = require("@welldone-software/why-did-you-render");

  whyDidYouRender(React, {
    trackAllPureComponents: true,
    logOnDifferentValues: true,
    collapseGroups: true,
    trackHooks: true,
  });
}

index.tsx

import './wdyr'; 
import React from 'react';
import { App } from './App';


const root = ReactDOM.createRoot(document.getElementById('app')!);
root.render(
    <App/>
);

App.tsx

export const App = memo(function App() {

    return(
	 <div> some text </div>
    );
})

If I remove wdyr or remove React.memo or will import through React.lazy it work fine.

If change it like this it work to:

App.tsx

export function AppWrapper() {

    return(
        <App />
    );
}

const App = memo(function App() {

	return(
	    <div> some  text</div>
	);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant