-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: codeSandbox error fixed in Select, SimpleSelect, Selectable #1669
chore: codeSandbox error fixed in Select, SimpleSelect, Selectable #1669
Conversation
|
eb11c8d
to
5bd5e82
Compare
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})` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old code split the code into lines and checked if the last line included 'render(<'. However, sometimes the last line was just a ')' despite the code ending in a render function. This resulted in multiple render functions in CodeSandbox. Now, all newline characters and extra spaces are removed from the code, and it is checked whether the code actually ends with render(<...>)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my comment
const codeBlock = shouldRender | ||
? `render(${this.props.code})` | ||
: this.props.code | ||
const cleanedCode = this.props.code.replace(/\s+/g, '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
regexp are so hard to read, please add here a comment on what this one does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment added
Closes: INSTUI-4201
5bd5e82
to
b232e42
Compare
Closes: INSTUI-4201
test plan: