esxjs / to-esx

Converts JSX and `React.createElement` into ESX
MIT License
5 stars 2 forks source link

esx.renderToString._r is not a function #3

Open irudoy opened 5 years ago

irudoy commented 5 years ago

Input

import React from 'react';
import ReactDOMServer from 'react-dom/server';

function foo() {
  const A = () => <div/>;
  ReactDOMServer.renderToString(<A/>);
};

Output

const esx = require('esx')();
import React from 'react';
import ReactDOMServer from 'react-dom/server';

function foo() {
  const A = () => esx `<div/>`;
  esx.renderToString._r("A", A) `<A/>`;
};
irudoy commented 4 years ago
test('React.renderToString inside a function', async ({ is }) => {
  const src =
`import React from 'react';
import ReactDOMServer from 'react-dom/server';
function foo() {
  const A = () => <div/>;
  ReactDOMServer.renderToString(<A/>);
};`
  const esx =
`const esx = require('esx')();
import React from 'react';
import ReactDOMServer from 'react-dom/server';
function foo() {
  const A = () => esx \`<div/>\`;
  esx.renderToString("A", A) \`<A/>\`;
};`
  is(convert(src), esx)
})