Code Monkey home page Code Monkey logo

Comments (5)

MyNameIsTakenOMG avatar MyNameIsTakenOMG commented on July 22, 2024 1

In my case, when I visited the route localhost:3000/booking for the first time, there was no error in the console( which also tricked me closing the issue ), but after that, when I started refreshing the page, the issue came up and stayed there. So I reopened the issue and wonder if there is a solution to fix it or maybe some hacky way so that I could just bypass this issue. Thanks in advance

from mui-x.

MyNameIsTakenOMG avatar MyNameIsTakenOMG commented on July 22, 2024 1

@michelengelen Thank you for your prompt reply, Sir! And by following your advice, I tested it out in Firefox, and this time there was no issue as expected, and also more weirder thing is when I switched back to the google chrome and gave it try again, the issue was not there anymore whether I turned on/off those plugins, just like what happened yesterday.

It seems this is some issue that could occur intermittently while we develop our projects as developers. So for that, please allow me to share some workarounds I found, hopefully it could help someone else who may get stuck with this sort of hydration issue during development at some point in the future:

'use client'
import React, { useState } from 'react'
import { LocalizationProvider } from '@mui/x-date-pickers';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'
// import TestCalendar from '@/components/TestCalendar';

import dynamic from 'next/dynamic';

const ClientCalendar1 = dynamic(() => import('@/components/TestCalendar'), { ssr: false })

const ClientCalendar2 = dynamic(() => import('@/components/TestCalendar'))

export default function Booking() {

  const [show, setShow] = useState(false)

  return (
    <LocalizationProvider dateAdapter={AdapterDayjs}>

      {/* only load at the client side */}
      <ClientCalendar1 />

      {/* load conditionally */}
      {show && <ClientCalendar2 />}
      <button onClick={() => setShow(!show)}>toggle</button>

      {/* <TestCalendar /> */}

    </LocalizationProvider>
  )
}

These workaround are Nextjs way to handle SSR, which basically help us skip SSR, so that it is ensured that we are 100% safe to use or test our components no matter what.

Okay, thanks again Sir! And my apology for any trouble caused by this wrong alarm. So I will close this issue now

from mui-x.

github-actions avatar github-actions commented on July 22, 2024

⚠️ This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

@MyNameIsTakenOMG: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

from mui-x.

michelengelen avatar michelengelen commented on July 22, 2024

Hey @MyNameIsTakenOMG I cannot reproduce this issue.
But I can see that you have some plugins installed, right?
This can sometimes lead to weird next js bugs and should disappear when in production.
Try opening the page in a different browser or in privacy mode.

from mui-x.

github-actions avatar github-actions commented on July 22, 2024

⚠️ This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

@MyNameIsTakenOMG: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

from mui-x.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.