Skip to content

Commit

Permalink
chore: codeSandbox error fixed in Select, SimpleSelect, Selectable
Browse files Browse the repository at this point in the history
Closes: INSTUI-4201
  • Loading branch information
ToMESSKa committed Sep 13, 2024
1 parent fa73851 commit b84b87c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/__docs__/src/CodeSandboxButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,16 @@ import 'moment/min/locales'
', '
)}} from "@instructure/ui"\n\n`

const codeLines = this.props.code.split('\n')
const shouldRender = !codeLines[codeLines.length - 1]
.split(' ')
.join('')
.includes('render(<')
const codeBlock = shouldRender
? `render(${this.props.code})`
: this.props.code
// removes all whitespace (spaces, tabs, newlines, etc.) from the code string
const cleanedCode = this.props.code.replace(/\s+/g, '')
const lastRenderIndex = cleanedCode.lastIndexOf('render(<')
const endsWithRenderStatement =
lastRenderIndex !== -1 && cleanedCode.endsWith('>)')

const codeBlock = endsWithRenderStatement
? this.props.code
: `render(${this.props.code})`

const renderStatement = `const render = (el) => { ReactDOM.render(el, document.getElementById('app')) }\n`
const codeSandboxData = {
title: this.props.title,
Expand Down

0 comments on commit b84b87c

Please sign in to comment.