Skip to content
This repository was archived by the owner on Jun 22, 2019. It is now read-only.

mapbox/remark-react-component

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

RemarkComponent


This project is no longer maintained. If you'd like to carry it forward, please fork the repository and release a new package.


Render Markdown in React, in a component.

This uses remark-react under the hood, so it does not use dangerouslySetInnerHTML, which means it doesn't do any innerHTML and has a smaller surface for security vulnerabilities than other approaches: its HTML output is guided by React's strict rules.

Installation

npm install --save remark-react-component

Usage

var React = require('react'),
    RemarkComponent = require('remark-react-component');

var App = React.createClass({
    getInitialState() {
      return { text: '# hello world' };
    },
    onChange(e) {
      this.setState({ text: e.target.value });
    },
    render() {
      return (<div>
        <textarea
          value={this.state.text}
          onChange={this.onChange} />
        <div id='preview'>
          <RemarkComponent>
            {this.state.text}
          </RemarkComponent>
        </div>
      </div>);
    }
});

React.render(<App />, document.getElementById('app'));

About

Render Markdown in React, in a component.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •