Closed vpanichkin closed 1 year ago
Hello @vpanichkin,
We researched this issue. It appears that regardless of the 'use client'
directive, the NextJS v14.0 application does not render the page entirely on the client. It still renders a component on the server side. You can use either of the options available in the official NextJS documentation: Text content does not match server-rendered HTML.
We used [Solution 1: Using useEffect to run on the client only](https://nextjs.org/docs/messages/react-hydration-error#solution-1-using-useeffect-to-run-on-the-client-only) and updated your demo: surveyjs-next13-demo.zip.
I also submitted a corresponding PR with required changes: https://github.com/vpanichkin/surveyjs-next13-bug-example/pull/1.
Additionally, I imported survey styles. Here is the resultant page.tsx
component's code:
'use client'
import { useEffect, useState } from 'react'
import { Model } from 'survey-core'
import { Survey } from 'survey-react-ui'
import 'survey-core/defaultV2.min.css';
export default function Home(){
const surveyJson = {
pages: [
{
elements: [
{
type: 'radiogroup',
name: 'some-radiogroup',
choices: ['a', 'b', 'c'],
},
],
},
],
}
const survey = new Model(surveyJson)
const [isClient, setIsClient] = useState(false)
useEffect(() => {
setIsClient(true)
}, [])
return isClient ? <Survey model={survey} /> : null
}
A survey appears as follows:
Please let us know if you have any further questions.
Thanks
Hey, @JaneSjs . Thanks for the commenting . I also solved the issue in this way
export default dynamic(() => Promise.resolve(Page), {
ssr: false,
})
Are you requesting a feature, reporting a bug or asking a question?
Bug
What is the current behavior?
What is the expected behavior?
No exception is thrown
How would you reproduce the current behavior (if this is a bug)?
yarn dev
Specify your
Suggestion to fix