Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@CNSeniorious000
Copy link
Contributor

Description

fix #26

Linked Issues

fix #26

Additional context

I have to add a getClass() function to retain reactivity:

export default (props: Props) => {
  const htmlString = () => props.showRawCode ? props.text : parseMarkdown(props.text)
+ const getClass = () => `${props.class ?? ''} ${props.showRawCode ? 'whitespace-pre-wrap overflow-auto my-0' : ''}`

  return props.showRawCode
    ? <div class={getClass()} innerText={htmlString()} />
    : <div class={getClass()} innerHTML={htmlString()} />
}

or I have to write it twice, which is more repetitive:

export default (props: Props) => {
  const htmlString = () => props.showRawCode ? props.text : parseMarkdown(props.text)

  return (
    props.showRawCode
      ? <div
          class={`${props.class ?? ''} ${props.showRawCode ? 'whitespace-pre-wrap overflow-auto my-0' : ''}`}
          innerText={htmlString()}
        />
      : <div
          class={`${props.class ?? ''} ${props.showRawCode ? 'whitespace-pre-wrap overflow-auto my-0' : ''}`}
          innerHTML={htmlString()}
        />
  )
}

I wonder if there is a way to implement it more elegantly.

@netlify
Copy link

netlify bot commented May 15, 2023

Deploy Preview for chatgpt-demo-v2 ready!

Name Link
🔨 Latest commit bb59cdc
🔍 Latest deploy log https://app.netlify.com/sites/chatgpt-demo-v2/deploys/6462868cab607a0008574db6
😎 Deploy Preview https://deploy-preview-27--chatgpt-demo-v2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Display unescaped HTML code when showRawCode is true.

1 participant