Skip to content

Commit

Permalink
chore(readme): Add render function to getting started (#94)
Browse files Browse the repository at this point in the history
related to #92
  • Loading branch information
IanEdington authored Feb 24, 2023
1 parent e8befa5 commit bf5ee25
Showing 1 changed file with 32 additions and 10 deletions.
42 changes: 32 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[Jump to getting started](#getting-started)

## Annoucement from Engineering @ Faire

Hello mjml community, we at Faire are excited to announce we will be taking over maintaining the open-source mjml-react project!
Expand Down Expand Up @@ -37,17 +39,39 @@ In V4 we are exploring exciting features that will make mjml-react even more pow

If you want to be on the cutting edge of what is being released, we are publishing a [v4-main-alpha version](https://www.npmjs.com/package/@faire/mjml-react/v/main-alpha) to npm.

## How it works
## Getting Started

1. Choose between rendering in mjml or mjml-browser based on your rendering environment. Also includes additional required dependencies.

Install the required dependencies first:
node:

```bash
npm install react react-dom mjml @faire/mjml-react
npm install @faire/mjml-react mjml react react-dom
```

And afterwards write a code like a pro:
browser:

```js
```bash
npm install @faire/mjml-react mjml-browser react react-dom
```

2. Wire up your render function (uncomment `mjml` or `mjml-browser`)

```tsx
import { renderToMjml } from "@faire/mjml-react/utils/renderToMjml";
// import mjml2html from "mjml";
// import mjml2html from "mjml-browser";
import { MJMLParseResults } from "mjml-core";
import React from "react";

export function renderReactToMjml(email: React.ReactElement): MJMLParseResults {
return mjml2html(renderToMjml(email));
}
```

3. And afterwards write a code like a pro:

```tsx
import {
Mjml,
MjmlHead,
Expand All @@ -59,12 +83,10 @@ import {
MjmlButton,
MjmlImage,
} from "@faire/mjml-react";
// The below render import was previously:
// import { render } from "@faire/mjml-react/dist/src/utils/render";
// Please migrate to importing from "@faire/mjml-react/utils/render"
import { render } from "@faire/mjml-react/utils/render";

const { html, errors } = render(
import { renderReactToMjml } from "./renderReactToMjml";

const { html, errors } = renderReactToMjml(
<Mjml>
<MjmlHead>
<MjmlTitle>Last Minute Offer</MjmlTitle>
Expand Down

0 comments on commit bf5ee25

Please sign in to comment.