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

Upgrade to react 18 #176

Closed
wants to merge 19 commits into from
Closed

Conversation

tbragaf
Copy link
Collaborator

@tbragaf tbragaf commented Feb 15, 2024

I still need to run some tests first locally, but this PR serves as a tentative react upgrade

  • Fix navigation.reload() rendering 2 same widgets
  • Run all tests (view ones as well)

Copy link
Collaborator

@joaompneves joaompneves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deprecated APIs should be replaced:
eg: https://react.dev/reference/react-dom/hydrate

@tbragaf tbragaf marked this pull request as draft February 15, 2024 11:40
return new Promise<void>(resolve => {
const root = ReactDOMClient.hydrateRoot(container, children);
root.render(children);
resolve();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still trying to figure out how to resolve this promise now

mounted?.();
}, []);

return isMounted ? <>{children}</> : <></>;
Copy link
Collaborator Author

@tbragaf tbragaf Feb 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed this isMounted because I was getting updates after the hydration - which shouldn't happen. The following error was appearing

Screenshot 2024-02-16 at 14 57 16

await loadScript(externalLibsPath + "react/umd/react.production.min.js", view); /* React */
await loadScript(externalLibsPath + "react-dom/umd/react-dom.production.min.js", view); /* ReactDOM */

await loadScript(externalLibsPath + "react/umd/react.development.js", view); /* React */
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not merge this

@@ -102,10 +103,12 @@

<ItemGroup>
<EmbeddedResource Include="node_modules\react\umd\react.production.min.js" />
<EmbeddedResource Include="node_modules\react\umd\react.development.js" />
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not merge

@@ -10,6 +10,7 @@
<UseWpf>true</UseWpf>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
<Configurations>Debug;Release;ReleaseAvalonia;ReleaseWPF</Configurations>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not merge

}

export function ComponentWithMountCallback({ mounted, children }: PropsWithChildren<IComponentWithMountCallbackProps>): JSX.Element | null {
const [isMounted, setIsMounted] = useState(false);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use ref... otherwise this leads to an extra render

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i actually wanted this way because I was getting a crash stating that there was a render after the hydration
this is basically avoiding 1 render to fix that hydration issue - by postponing the render in a way

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don get it... I stand with my opinion

@tbragaf tbragaf closed this Mar 13, 2024
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

Successfully merging this pull request may close these issues.

None yet

2 participants