Skip to content
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

Fails on SSR #136

Closed
adam-26 opened this issue Oct 20, 2017 · 5 comments
Closed

Fails on SSR #136

adam-26 opened this issue Oct 20, 2017 · 5 comments

Comments

@adam-26
Copy link

adam-26 commented Oct 20, 2017

Hi,

The measureScollbar() utility method uses the document object that is not available on nodejs.
See it here.

This causes the error ReferenceError: document is not defined when rendering is attempted on nodejs.

Adam.

@wayne1203
Copy link

Is it the same problem?
2017-10-26 2 21 35

@adam-26
Copy link
Author

adam-26 commented Oct 26, 2017

@wayne1203, looks like it is the same problem

@wayne1203
Copy link

@adam-26 Are you using RN 0.49 too??

@EtienneLem
Copy link
Member

v2.1.2 has been released, let me know if you’re still having issues with SSR.

@iksent
Copy link

iksent commented Jul 23, 2020

document is not defined
ReferenceError: document is not defined
    at _convertStyleToCSS (...\node_modules\emoji-mart\dist\components\emoji\nimble-emoji.js:94:13)

Using it with Next.js:

import { getEmojiDataFromNative } from 'emoji-mart/dist/utils'
import NimbleEmoji from 'emoji-mart/dist/components/emoji/nimble-emoji'
import appleEmojis from 'emoji-mart/data/apple.json'
import emojiRegexp from 'emoji-regex'

export const unicodeEmojiRegexp = emojiRegexp()

const prepareText = (content: string): string => {
  return content
    ? content
        .replace(unicodeEmojiRegexp, (emoji: string) => {
          const emojiData = getEmojiDataFromNative(emoji, 'apple', appleEmojis)
          return !emojiData
            ? ''
            : NimbleEmoji({
                data: appleEmojis,
                html: true,
                emoji: emojiData,
                skin: emojiData.skin || 1,
                set: 'apple',
                size: 18,
                sheetSize: 32,
              })
        })
        .replace('<a href', '<a target="_blank" href')
    : '-'
}

const EditorPostViewer = (props) => {
  const { text } = props

  return (
    <div dangerouslySetInnerHTML={{ __html: prepareText(text) }} />
  )
}

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

No branches or pull requests

4 participants