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

Convert network overlay to use flatlist #21837

Conversation

AlanFoster
Copy link
Contributor

Test Plan:

I ran through the following scenarios:

  • No Requests
  • New Requests coming in, an ensuring that scroll to bottom works as expected
  • Testing both XHR + WebSocket events
  • Focusing on a particular request/response element
  • Closing the detail view

network-update

Release Notes:

Help reviewers and the release process by writing your own release notes. See below for an example.

[GENERAL] [ENHANCEMENT] [Network Inspector] - The network inspector has been updated to use FlatList, as ListView has been marked as deprecated.

@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@AlanFoster AlanFoster force-pushed the convert-network-overlay-to-use-flatlist branch from f2487aa to d3073f5 Compare October 17, 2018 21:56
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 17, 2018
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

const networkRequestInfo = requests[socketIndex];
networkRequestInfo.status = statusCode;
networkRequestInfo.closeReason = closeReason;
return {requests};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a massive fan of the localised state mutation, but it feels like an improvement to the existing code.
I assumed the previous mutation was for performance reasons, and I've aligned with the most simplistic approach for now.

@AlanFoster AlanFoster force-pushed the convert-network-overlay-to-use-flatlist branch from d3073f5 to c09fc6d Compare October 17, 2018 23:10
@elicwhite
Copy link
Member

Thanks for this! I was just looking today at how this is one of the only callsites of ListView in the repo.

Unfortunately, this PR is huge and makes it hard to read through and see what changes are necessary to each piece. Can you break this into a couple different changes?

  • ListView -> FlatList
  • Changing styles
  • Changing the usage of setState

Each of these changes seem like they could be done in isolation. It would be greatly appreciated if you could make it as easy as possible to review your changes. We definitely want these things to land.

@AlanFoster
Copy link
Contributor Author

@TheSavior I agree - it's quite the PR. The code in the file was previously quite complected, but thankfully it's a single component still!

Can you break this into a couple different changes?

  • ListView -> FlatList
  • Changing styles
  • Changing the usage of setState

The main responsibilities are:

  • The network handling logic is between lines 89-300, and is mostly just updating mutation of this._requests to instead be calls to setState
  • The rest of the file is ListView -> FlatList, with the changes to styles being minimal with simple changes to align with using FlatList

I can try to extract this into two separate commits, but the commits wouldn't be atomic as they wouldn't work in isolation without lots of extra glue code to help with an intermediate step, which might make the review more confusing!

Let me know if the additional insights make this PR easier to review, or if you'd still like two separate commits :]

@elicwhite
Copy link
Member

Thanks for that explanation. I'm not sure I understand why the changes to network handling logic / setState are deeply coupled to ListView/FlatList. Can you help me understand this better? It seems like it should be possible to migrate to FlatList without also migrating the business logic very much.

@AlanFoster
Copy link
Contributor Author

It seems like it should be possible to migrate to FlatList without also migrating the business logic very much.

@TheSavior That was my initial plan too, but once I learnt what the existing code was doing - it ended up easier to modify the code to be closer to idiomatic React. Let me know your thoughts after you've had a chance to review it 👍

@elicwhite
Copy link
Member

I tried to import the PR to test it manually but noticed that your target branch is 0.57-stable. Our tooling can only handle PRs onto master. Can you rebase?

@AlanFoster AlanFoster force-pushed the convert-network-overlay-to-use-flatlist branch from c09fc6d to 60a222b Compare October 18, 2018 18:02
@AlanFoster
Copy link
Contributor Author

@TheSavior Done! Apologies :)

@AlanFoster AlanFoster changed the base branch from 0.57-stable to master October 18, 2018 18:02
@AlanFoster AlanFoster force-pushed the convert-network-overlay-to-use-flatlist branch from 60a222b to 375c8c2 Compare October 18, 2018 18:03
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TheSavior has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@react-native-bot
Copy link
Collaborator

@AlanFoster merged commit efa6016 into facebook:master.

@facebook facebook locked as resolved and limited conversation to collaborators Oct 23, 2018
@react-native-bot react-native-bot added the Merged This PR has been merged. label Oct 23, 2018
@AlanFoster AlanFoster deleted the convert-network-overlay-to-use-flatlist branch October 23, 2018 13:40
t-nanava pushed a commit to microsoft/react-native-macos that referenced this pull request Jun 17, 2019
Summary: Pull Request resolved: facebook#21837

Reviewed By: TheSavior

Differential Revision: D10449940

Pulled By: RSNara

fbshipit-source-id: 28dcd5906c64070ef50867425ae7517d391300e2
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants