Skip to content

Commit

Permalink
docs: update demo template (#35440)
Browse files Browse the repository at this point in the history
  • Loading branch information
MadCcc committed May 9, 2022
1 parent be982e1 commit c897728
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions site/theme/template/Content/Demo/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,10 @@ class Demo extends React.Component {
'const { $1 } = ReactRouterDOM;',
)
.replace(/([A-Za-z]*)\s+as\s+([A-Za-z]*)/, '$1:$2')
.replace(/export default/, 'const Demo =')}\n\n${
react18 ? 'createRoot(mountNode).render(<Demo />)' : 'ReactDOM.render(<Demo />, mountNode)'
.replace(/export default/, 'const ComponentDemo =')}\n\n${
react18
? 'createRoot(mountNode).render(<ComponentDemo />)'
: 'ReactDOM.render(<ComponentDemo />, mountNode)'
};\n`,
css: prefillStyle,
editors: '001',
Expand Down Expand Up @@ -253,8 +255,10 @@ class Demo extends React.Component {
react18
? `import React from 'react';\nimport { createRoot } from 'react-dom/client';\n`
: ''
}${sourceCode.replace(/export default/, 'const Demo =')}\n\n${
react18 ? 'createRoot(mountNode).render(<Demo />)' : 'ReactDOM.render(<Demo />, mountNode)'
}${sourceCode.replace(/export default/, 'const ComponentDemo =')}\n\n${
react18
? 'createRoot(mountNode).render(<ComponentDemo />)'
: 'ReactDOM.render(<ComponentDemo />, mountNode)'
};\n`,
css: prefillStyle,
json: JSON.stringify(
Expand Down

0 comments on commit c897728

Please sign in to comment.