Skip to content

Commit 64a485d

Browse files
authored
docs(Calendar): fix first-click issue on documentation site (#8459)
* docs(Calendar): fix first-click issue with SSR-safe appendTo * style(docs): format calendar basic demo with Prettier
1 parent 6db5fa0 commit 64a485d

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

components/doc/calendar/basicdoc.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ export function BasicDoc(props) {
88

99
const code = {
1010
basic: `
11-
<Calendar value={date} onChange={(e) => setDate(e.value)} />
11+
<Calendar
12+
value={date}
13+
onChange={(e) => setDate(e.value)}
14+
appendTo={typeof window !== 'undefined' ? document.body : null}
15+
/>
1216
`,
1317
javascript: `
1418
import React, { useState } from "react";
@@ -19,7 +23,11 @@ export default function BasicDemo() {
1923
2024
return (
2125
<div className="card flex justify-content-center">
22-
<Calendar value={date} onChange={(e) => setDate(e.value)} />
26+
<Calendar
27+
value={date}
28+
onChange={(e) => setDate(e.value)}
29+
appendTo={typeof window !== 'undefined' ? document.body : null}
30+
/>
2331
</div>
2432
)
2533
}
@@ -34,7 +42,11 @@ export default function BasicDemo() {
3442
3543
return (
3644
<div className="card flex justify-content-center">
37-
<Calendar value={date} onChange={(e) => setDate(e.value)} />
45+
<Calendar
46+
value={date}
47+
onChange={(e) => setDate(e.value)}
48+
appendTo={typeof window !== 'undefined' ? document.body : null}
49+
/>
3850
</div>
3951
)
4052
}
@@ -49,7 +61,7 @@ export default function BasicDemo() {
4961
</p>
5062
</DocSectionText>
5163
<div className="card flex justify-content-center">
52-
<Calendar value={date} onChange={(e) => setDate(e.value)} />
64+
<Calendar value={date} onChange={(e) => setDate(e.value)} appendTo={typeof window !== 'undefined' ? document.body : null} />
5365
</div>
5466
<DocSectionCode code={code} />
5567
</>

0 commit comments

Comments
 (0)