# transformime-react

> Transformime that returns React components

Latest version **1.1.0** (published 2016-09-03) · BSD-3-Clause license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install transformime-react
pnpm add transformime-react
yarn add transformime-react
bun add transformime-react
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2016-09-03 |
| First published | 2016-01-02 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Kyle Kelley |
| Maintainers | betatim, jdfreder, rgbkrk, thekenwheeler |

## Links

- npm: https://www.npmjs.com/package/transformime-react
- Repository: https://github.com/nteract/transformime-react
- Homepage: https://github.com/nteract/transformime-react#readme
- Issues: https://github.com/nteract/transformime-react/issues
- npm.io page: https://npm.io/package/transformime-react

## Dependencies (4)

- [commonmark](https://npm.io/package/commonmark.md) ^0.26.0
- [ansi-to-react](https://npm.io/package/ansi-to-react.md) 0.0.4
- [mathjax-electron](https://npm.io/package/mathjax-electron.md) ^1.1.0
- [commonmark-react-renderer](https://npm.io/package/commonmark-react-renderer.md) ^4.3.1

## Recent versions

- 1.1.0 (latest) — 2016-09-03
- 1.0.2 — 2016-08-24
- 1.0.1 — 2016-05-06
- 1.0.0 — 2016-05-05
- 0.7.0 — 2016-05-05
- 0.6.2 — 2016-05-05
- 0.6.1 — 2016-05-03
- 0.6.0 — 2016-04-23
- 0.5.0 — 2016-04-09
- 0.4.0 — 2016-03-19
- 0.3.0 — 2016-01-06
- 0.2.2 — 2016-01-04
- 0.2.1 — 2016-01-04
- 0.2.0 — 2016-01-03
- 0.1.0 — 2016-01-03
- … 2 more at https://npm.io/package/transformime-react/versions

## README

# transformime-react

[![Build Status](https://travis-ci.org/nteract/transformime-react.svg)](https://travis-ci.org/nteract/transformime-react)

Transforms MIMEtype+data to pure React Elements.

![Optimus MIME](https://cloud.githubusercontent.com/assets/6437976/8895696/db154a04-3397-11e5-91ca-296b957658a6.png)

## Installation

```
npm install transformime-react
```

Note that `react` and `immutable` are peer dependencies; you'll need to install those as well if they're not in your project (hint: they're definitely needed to make this package useful at all).

```
npm install immutable@3.7.x react@0.14.x
```

## Usage

```es6
import { richestMimetype, transforms } from 'transformime-react';
import Immutable from 'immutable';

// Jupyter style MIME bundle
const bundle = new Immutable.Map({
  'text/plain': 'This is great',
  'image/png': 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
});

// Find out which mimetype is the richest
const mimetype = richestMimetype(bundle); 

// Get the matching React.Component for that mimetype
let Transform = transforms.get(mimetype);

// Create a React element
return <Transform data={bundle.get(mimetype)} />;
```

which will return:

```jsx
<img src='data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7' />
```

as a React element. It chose 'image/png' as richer than 'text/plain' for representation.

### Override the default transforms and display order

```es6
const myOrder = Immutable.List(['text/plain', 'image/png']);

const CodeAsText = React.createClass({
  render: function() {
    return (
      <code>{this.props.data}</code>
    );
  }
});

const myTransforms = transforms.set('text/plain', CodeAsText);

const mimetype = richestMimetype(bundle, myOrder, myTransforms); 
Transform = myTransforms.get(mimetype);

return <Transform data={bundle.get(mimetype)} />;
```

Using the bundle from above, we'll get back:

```jsx
<code>This is great</code>
```

---
_Source: https://npm.io/package/transformime-react · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
