lxsmnsyc / forgetti

Solve your hook spaghetti (with more spaghetti). Inspired by React Forget.
https://forgetti.vercel.app/
MIT License
352 stars 7 forks source link

Can not transform components defined with `VariableDeclaration` #10

Closed SukkaW closed 1 year ago

SukkaW commented 1 year ago

Input

export const Example = () => {
  const value = [1, 2, 3, 4];

  return (
    <div>
      {value.map(i => <p key={i}>{i}</p>)}
    </div>
  );
};

Output

import { jsx as _jsx } from "react/jsx-runtime";
export const Example = function _Component() {
    const value = [
        1,
        2,
        3,
        4
    ];
    return /*#__PURE__*/ _jsx("div", {
        children: value.map((i)=>/*#__PURE__*/ _jsx("p", {
                children: i
            }, i))
    });
};

Forgetti simply doesn't transform the component here.

lxsmnsyc commented 1 year ago

Hmmm, weird, I thought I tested this

lxsmnsyc commented 1 year ago

Should be fixed in 0.4.5

SukkaW commented 1 year ago

Should be fixed in 0.4.5

I can confirm that 0.4.5 has fixed the issue! Great jobs!