ramasilveyra / unreact

Convert React Components to EJS or Pug [Alpha][Unreleased]
MIT License
14 stars 3 forks source link

Add support for React.Fragment #10

Open alejofernandez opened 6 years ago

alejofernandez commented 6 years ago

Currently they translate to <undefined>:

<undefined>
  <form class=\"ulp-form\" method=\"post\"><input name=\"state\" type=\"hidden\" value=\"T-jbV6hF5ubZ8kk2uZcPVzr50qpAi486\">
    <div class=\"input-container code\">
      <label for=\"code\">code</label>
      <input name=\"code\" type=\"text\" value=\"\" class=\"input\" id=\"code\" placeholder=\"Enter the code you received\" required>
    </div>
    <button class=\"ulp-button ulp-button-default\" type=\"submit\">Continue</button>
  </form>
  <p style=\"margin:5px 0 0 0\">Didn't get the code?</p>
  <form class=\"ulp-action-form\" method=\"POST\">
    <input name=\"state\" type=\"hidden\" value=\"T-jbV6hF5ubZ8kk2uZcPVzr50qpAi486\">
    <input name=\"action\" type=\"hidden\" value=\"resend-code\">
    <input name=\"data\" type=\"hidden\" value=\"\">
    <button class=\"ulp-action-link-button link link-retry\" type=\"submit\">Resend</button>
  </form>
  <p></p>
</undefined>
ramasilveyra commented 6 years ago

<></> syntax is supported and this case was fixed with https://github.com/ramasilveyra/unreact/commit/71a53c7e121fceddc6fa92df8b7b4aac5e45ee69:

import React from 'react';
import PropTypes from 'prop-types';
 const Foo = () => (
  <React.Fragment>
    <h1>Hi!</h1>
    <p>Bye</p>
  </React.Fragment>
);
 export default Foo;

But this case is the only one missing:

import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
 const Foo = () => (
  <Fragment>
    <h1>Hi!</h1>
    <p>Bye</p>
  </Fragment>
);
 export default Foo;