vscode-glean icon indicating copy to clipboard operation
vscode-glean copied to clipboard

In simple component, seems like parameters not extracted

Open pkellner opened this issue 4 years ago • 2 comments

I'm having trouble figuring out if this is a limitation of glean or there is something else going on. Below is a simple component with an extra layer of nesting.

When I "Extract Component" the sessions.map(... piece (surrounded by the div), it extracts id and title but leaves out the array sessions so that the refactoring fails. (code pasted below below).

const data = [
  {
    id: "1269",
    first: "Ronald",
    last: "Reagan",
    sessions: [
      {
        id: "32",
        title: "Rails powered by GlassFish",
        room: {
          name: "Cornell Hall",
        },
      },
    ],
  },
  {
    id: "8590",
    first: "Jimmy",
    last: "Carter",
    sessions: [
      {
        id: "1011",
        title: "Decomposing applications for scalability and deployability",
        room: {
          name: "4306",
        },
      },
    ],
  },
];

const IndexPage = () => {
  return (
    <div>
      {data.map(function ({ id, first, last, sessions }) {
        return (
          <div key={id}>
            {first} {last}
            <div>
              {sessions.map(function ({ id, title }) {
                return (
                  <div key={id}>
                    <div>&nbsp;{title}</div>
                  </div>
                );
              })}
            </div>
          </div>
        );
      })}
    </div>
  );
};

export default IndexPage;

Extracted Component:

const IndexPage = () => {
  return (
    <div>
      {data.map(function ({ id, first, last, sessions }) {
        return (
          <div key={id}>
            {first} {last}
            <Sessions id={id} title={title} />
          </div>
        );
      })}
    </div>
  );
};

export default IndexPage;

function Sessions({ id, title }) {
  return (
    <div>
      {sessions.map(function ({ id, title }) {
        return (
          <div key={id}>
            <div>&nbsp;{title}</div>
          </div>
        );
      })}
    </div>
  );
}

pkellner avatar Feb 22 '21 00:02 pkellner

Hey! @pkellner Ill have a look ASAP. Thanks for the isseu!

borislit avatar Apr 07 '21 20:04 borislit

no rush.

On Wed, Apr 7, 2021 at 1:34 PM Boris Litvinsky @.***> wrote:

Hey! @pkellner https://github.com/pkellner Ill have a look ASAP. Thanks for the isseu!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/wix/vscode-glean/issues/129#issuecomment-815243472, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB24EXJDT4MQXAMFRLBMEDTHS6ULANCNFSM4X7QTMOQ .

-- Peter Kellner https://www.linkedin.com/in/peterkellner99 https://twitter.com/pkellner

pkellner avatar Apr 07 '21 21:04 pkellner