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

Passing ref={ref} to a markdownRule component causes app to become unresponsive #223

Open
jdatcharacter opened this issue Aug 15, 2024 · 1 comment

Comments

@jdatcharacter
Copy link

Simulating on iPhone 15

"react-native": "0.72.12",
"react-native-markdown-display": "7.0.0-alpha.2",
// custom render method
const renderText = (textRef, node, ...args) => {
  return <Text ref={textRef}>{node.content}</Text>
}
const MyComponent = () => {
  const textRef = React.useRef(null)

  const markdownRules = {
    text: (...args) => renderText(textRef, ...args);
  }

  return (<Markdown rules={markdownRules} style={markdownTheme}>
      {message.raw_content}
    </Markdown>)
}

Has this been reported before? Seems like refs may not be passed correctly or something funky is going on.

@jdatcharacter
Copy link
Author

After digging a little deeper into the react native Text docs, it may be because nested text nodes are resolved into a single text node - making a ref to a nested text impossible.

Trying to add a custom style to a text node using a view wrapper - doesn't seem to be possible if any parent nodes are Text nodes. Any thoughts welcome.

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

1 participant