Created
March 20, 2020 13:06
-
-
Save DominikAngerer/045363c80d223853a1e9da96228c0dff to your computer and use it in GitHub Desktop.
Storyblok RichTextRenderer without token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import StoryblokClient from 'storyblok-js-client' | |
// Storyblok is now available as variable which contains the richTextResolver functionality | |
const Storyblok = new StoryblokClient({}) | |
function createMarkup(storyblokHTML) { | |
return { | |
__html: Storyblok.richTextResolver.render(storyblokHTML), | |
} | |
} | |
const RichTextField = ({ data }) => { | |
return <div dangerouslySetInnerHTML={createMarkup(data)} /> | |
} | |
export default RichTextField | |
// Usage in other components -> import that richTextField Component | |
// and use like: <RichTextField data=your_field></RichTextField> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment