Skip to content

Instantly share code, notes, and snippets.

@productioncoder
Last active November 4, 2018 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save productioncoder/a388a9b34d4176113385f7c1428092f1 to your computer and use it in GitHub Desktop.
Save productioncoder/a388a9b34d4176113385f7c1428092f1 to your computer and use it in GitHub Desktop.
Youtube in React: properly formatting video description
import Linkify from 'react-linkify';
getDescriptionParagraphs() {
const videoDescription = this.props.video.snippet ? this.props.video.snippet.description : null;
if (!videoDescription) {
return null;
}
return videoDescription.split('\n').map((paragraph, index) => <p key={index}><Linkify>{paragraph}</Linkify></p>);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment