-
Notifications
You must be signed in to change notification settings - Fork 801
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
! THIS IS NOT YOUR COMPONENT ! #1311
Comments
None of the mentioned fixes worked for me, what worked was changing the default react-hot-reload lib to another one such as webpack-hot-reload lib. // webpack.conf
module.exports = {
...
entry: [
"webpack/hot/dev-server.js", // <-- change to this
...
],
output:{
publicPath: '/' // <-- Webpack hot reload require this param to work properly
},
devServer: {
hot: true,
},
...
} (I was using React v17 and Router v6) |
I am facing this issue and it is not working for me |
Tried all of the above methods and still have same problem None of the above solutions work for this repo: index.tsx import React, { ComponentType } from "react";
import ReactDOM from "react-dom";
import { AppContainer } from "react-hot-loader";
import App, { Props as AppProps } from "src/App";
import './index.scss'
export interface RenderProps {
App: ComponentType<AppProps>;
}
export type TRender = (props: RenderProps) => void;
export const render: TRender = ({ App }) => {
ReactDOM.render(
<AppContainer>
<App />
</AppContainer>,
document.getElementById("root") || document.createElement("div")
);
};
interface HotProps extends RenderProps {
render: TRender;
}
type THot = (props: HotProps) => void;
const handleHotReload: THot = ({ render, App }) => {
if (module && module.hot) {
module.hot.accept("src/App", () => {
return render({ App });
});
}
};
render({ App });
handleHotReload({ render, App });
export default {}; App.tsx import React, { FC, useEffect } from "react";
import {
Routes,
Route,
BrowserRouter as Router
} from "react-router-dom";
import { Home } from "./Pages";
import { Example } from "./Pages/Example";
import { TElement } from "./types";
export interface ConfigRoutes {
[key: string]: {
title: string,
path: string,
component: TElement
}
}
export const configRoutes: ConfigRoutes = {
home: {
title: "Home",
path: `/`,
component: <Home />,
},
Example: {
title: "Example",
path: `/Example`,
component: <Example />,
},
};
export interface Props {
}
const App:FC<Props> = () => {
const routes = configRoutes
// const location = useLocation()
const location = document.location;
const { pathname } = location;
useEffect(() => {
if (pathname) {
const keyRoute = Object.keys(routes).find(
(item) => routes[item].path === pathname
);
if (keyRoute) {
const title = routes[keyRoute].title;
window.document.title = title;
}
}
}, [pathname]);
console.log('Router', {routes})
return (
<Router>
<Routes>
{Object.keys(routes).map((key) => (
<Route
path={routes[key].path}
element={routes[key].component}
key={`route-${key}`}
/>
))}
</Routes>
</Router>
);
};
export default App |
Ok I've bit the bullet and changed the npm package to - react-refresh - as advised from this README My updated repo: |
It works for me (the first way). Thank you so much |
You might see this in your code, especially if you clicked "Show Component Source" in the React Dev Tools.
You were looking for some component, and got
ProxyFacade
- that's how React-Hot-Loader works - it's wrapping everything with Proxies.And you can fix it!
To fix this problem you need "react-🔥-patch", and there are tree ways how to apply it:
Webpack loader
Use a webpack-plugin to land a patch. That's the safest way.
hot-loader/react-dom alias
Use a hot-loader/react-dom with prelanded patch. See hot-loader repo for the instalation details.
hot-loader/react-dom yarn override
Just
yarn add react-dom@npm:@hot-loader/react-dom
, but only foryarn
package manager.The text was updated successfully, but these errors were encountered: