Directory / front-end-core-components / Markdown.md

You are browsing a mirror of a file hosted on GitHub. View original

Markdown

Markdown renderer, essentially a wrapper for react-markdown providing a way of setting global default props via the React Context API.

Dependencies

  • react ^16.3
  • prop-types ^15.6.2
  • react-markdown ^4.2.2

Reference

Provider

prop namedescriptiontyperequired?default value
markdownPropsProps forwarded to ReactMarkdownArray<Object>-
childrenChild nodesNode-

Markdown

See ReactMarkdown for available props. Will consume props from Provider where specified, any props defined directly on Markdown will overwrite props set via the Provider.

Usage

Provider (optional)

Put the provider high up in your application component tree, usually within App.js or the main entry point to your application/website.

import React from 'react'
import { Provider } from '@input-output-hk/front-end-core-components/components/Markdown'

export default () => (
  <Provider markdownProps={{ ... }}>
    ...
    <p>The rest of your app</p>
    ...
  </Provider>
)

Markdown

import React from 'react'
import Markdown from '@input-output-hk/front-end-core-components/components/Markdown'

export default () => (
  <Markdown>
    {myMarkdown}
  </Markdown>
)