Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In simple component, seems like parameters not extracted #129

Open
pkellner opened this issue Feb 22, 2021 · 2 comments
Open

In simple component, seems like parameters not extracted #129

pkellner opened this issue Feb 22, 2021 · 2 comments

Comments

@pkellner
Copy link

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>
  );
}
@borislit
Copy link
Contributor

borislit commented Apr 7, 2021

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

@pkellner
Copy link
Author

pkellner commented Apr 7, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants