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 18 not working ! #573

Open
ahmadzreqat opened this issue Apr 11, 2023 · 10 comments
Open

React 18 not working ! #573

ahmadzreqat opened this issue Apr 11, 2023 · 10 comments

Comments

@ahmadzreqat
Copy link

Bug Report

Current Behavior
A clear and concise description of the behavior.

Reproducible demo
Link to GitHub repository or codesandbox with a demo of the bug behavior.

Expected behavior/code
A clear and concise description of what you expected to happen (or code).

Possible Solution

Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.

@ahmadzreqat
Copy link
Author

not working with react dom v: 18

@jason-hwang
Copy link

jason-hwang commented Aug 25, 2023

Hi guys, Is there any updates for React 18?

@WillSmithTE
Copy link

Aww sad to hear, I was about to try it out. Did you ever find a workaround or alternative?

@loganknecht
Copy link

Encountering the same issue with this. 😭

@Nayem55
Copy link

Nayem55 commented Nov 9, 2023

@Abhishek1350 Thank you . It works but the styles are broken . Do you have any solution for that?

@Abhishek1350
Copy link

Abhishek1350 commented Nov 9, 2023

@Nayem55 Not sure about the broken styles, But you can try these steps.

  1. Try hosting you app in different platforms like vercel and netlify ( these are free ) and see if the issue is still there.
  2. If you are using an CDN then try to revalidate it's cache.
  3. Try this
    Ref : https://github.com/stereobooster/react-snap#readme
    Screenshot 2023-11-09 162835

Also when you deploy your app, check the page content by clicking on "view page source" in the browser. And see if you are getting the expected page content.

Apply these steps one by one and let me know what works!

@Nayem55
Copy link

Nayem55 commented Nov 9, 2023

Okk .. I'll try this and let you know

@Rafaelceid
Copy link

Hello Guys,, do we have any news about any update of this library? is it still compatimple with react 18?

@moretime-dev
Copy link

moretime-dev commented Apr 17, 2024

Hey guys, just had the same problem. Looking at the React 18 API Docu, I solved it like this and it works. Hope it helps.

const rootElement = document.getElementById('root') as HTMLElement

const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement)

const queryClient = new QueryClient()

if (rootElement.hasChildNodes()) {
  ReactDOM.hydrateRoot(
    rootElement,
    <BrowserRouter>
      <Auth>
        <React.StrictMode>
          <QueryClientProvider client={queryClient}>
            <App />
          </QueryClientProvider>
        </React.StrictMode>
      </Auth>
    </BrowserRouter>
  )
} else {
  root.render(
     <BrowserRouter>
      <Auth>
        <React.StrictMode>
          <QueryClientProvider client={queryClient}>
            <App />
          </QueryClientProvider>
        </React.StrictMode>
      </Auth>
    </BrowserRouter>
  )
}

@bird-cage
Copy link

bird-cage commented Apr 26, 2024

I'm doing this, but it is still not working, see error below:

Using "react-dom": "~18.2.0", "react-router": "~6.22.0", and createBrowserRouter

import React from "react";
import { createRoot, hydrateRoot } from "react-dom/client";
import { App } from "@/components";

const rootElement = document.getElementById("app") as HTMLElement;

if (rootElement.hasChildNodes()) {
    hydrateRoot(
        rootElement,
        <React.StrictMode>
            <App />
        </React.StrictMode>,
    );
} else {
    createRoot(document.getElementById("app")!).render(
        <React.StrictMode>
            <App />
        </React.StrictMode>,
    );
}

ERROR

webpack 5.90.3 compiled successfully in 10248 ms
🔥  pageerror at /: SyntaxError: Unexpected token '.'

✅  crawled 1 out of 1 (/)

error An unexpected error occurred: "Command failed.

Any Ideas

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

9 participants