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
Error after renaming React Component: Uncaught Error: Element type is invalid: expected a string #332
Comments
Hi @theimowski I've recently encountered this as well. I will need to look into it but maybe @alfonsogarciacaro knows more about it. Can you also try using latest Fable v3.1.10? the template is at 3.1.5 |
Looks like a Fable issue |
Can you please try with 3.1.11? This is probably related to fable-compiler/Fable#2413 |
I've confirmed that the issue is fixed as of v3.1.11 so @theimowski can you also give it a try? |
It still doesn't fully work as expected in Fable 3.1.11. Trying to investigate this a bit further:
There's an FSHARP compilation error, but webpack compiles and treats the error as a warning, WDS refreshes the page and you can see the React error in subject rendered on screen
This might be some kind of race condition issue, on Feliz template if you rename in both files at the same time, it will usually work fine, however on a slightly bigger project, when renaming the component I can see following behaviour in logs (note the warning in the middle):
|
@theimowski I think this might actually be an edge case for the fast-refresh plugin where it should trigger a full page refresh upon changing the entry point file. I need to confirm the theory sometime: the problem will not occur when the referenced component is not in the entry point file. So if you have App.fs -> Middle.fs -> Main.fs (entry point) and you only change App.fs or Middle.fs Can you also try this out? |
@theimowski I've crossposted the issue on react-refresh#330 |
The react-refresh occurs when using latest webpack so I rolled back to webpack v4 until the issue is resolved and published a working Feliz template (now with more example components) as of v3.6 |
Thanks - yes indeed using new feliz template the refresh issue is gone. |
It's not impossible: probably requires emitting JS code that intentionally has some syntax errors to break what webpack is doing but I doubt anyone wants that (especially @alfonsogarciacaro) 😉 I think the current situation is fine because when webpack is emitting a warning, Fable is emitting an error which is a higher priority for the developer to fix. Once the Fable (compile) error is fixed, the webpack warning also disappears. Am I missing something? |
My personal preference would be that a failing step results in not executing steps that follow - otherwise you might observe stuff refreshing in your browser and you might get fooled that everything is fine, while your F# code is actually not compiling. |
But react-refresh will show you an error page in red with an error message on the browser even if the terminal shows a webpack warning |
I see - right, in that case it's fine. |
I just happen to read this thread while searching for other stuff. For information, since Fable 3.2.9 Fable will not emit JavaScript code if there is an F# compilation error. However, if there is Fable compilation error (like missing replacements) it will still emit JavaScript code and so trigger Webpack or any tooling listening to the files. |
Starting from scratch with Feliz template, I've made it run with
npm start
and then renamedHelloWorld
React Component inApp.fs
toHelloWorlds
.In result Fable compiles fine without any warnings, but React complains in the runtime (nothing gets rendered):
Seems it's some kind of caching issue - not sure if in fable itself or feliz plugin. After clearing
.fable
directory it works fineThe text was updated successfully, but these errors were encountered: