BuilderIO / mitosis

Write components once, run everywhere. Compiles to React, Vue, Qwik, Solid, Angular, Svelte, and more.
https://mitosis.builder.io
MIT License
12.46k stars 553 forks source link

HTML export does not support getters #232

Open samijaber opened 2 years ago

samijaber commented 2 years ago

Describe the bug Infinite loop when trying to use getter methods in useState and exporting to HTML

To Reproduce

import { useState } from '@builder.io/mitosis';
import { kebabCase } from 'lodash';

export default function SmileReviews(props) {
  const state = useState({
    get kebabCaseValue() {
      return kebabCase('testThat');
    },
  });

  return (
    <div data-user-kebab={state.kebabCaseValue}>
    </div>
  );
}

Expected behavior A clear and concise description of what you expected to happen.

Screenshots infinitely loops with the following error:

image

Additional context Add any other context about the problem here.

samijaber commented 2 years ago

Most likely induced by this call: https://github.com/BuilderIO/mitosis/blob/fdebe412793fd9f1438282b9cc72e5782504fd66/packages/core/src/generators/html.ts#L351

https://github.com/BuilderIO/mitosis/blob/4f41a2c2fab004dc4ebf4866c70c2cbb89d0de3b/packages/core/src/helpers/babel-transform.ts#L55-L57

PatrickJS commented 2 years ago

this is still an issue. I thought it was that bit of code too or maybe I was too tired.