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

flow: Annotate some more exported React components. #4914

Merged
merged 41 commits into from
Jul 28, 2021

Commits on Jul 27, 2021

  1. flow: Use Node type exported from React, instead of React$Node.

    These are equivalent, but Greg prefers this form because it seems
    cleaner. See
      https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/Flow.20types-first/near/1239060.
    chrisbobbe committed Jul 27, 2021
    Configuration menu
    Copy the full SHA
    bf967cb View commit details
    Browse the repository at this point in the history
  2. CreateGroupScreen [nfc]: Inline handleFilterChange.

    Like we did in 4aedc4c.
    chrisbobbe committed Jul 27, 2021
    Configuration menu
    Copy the full SHA
    cf222c4 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    3f3e68b View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    3c95507 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    3293476 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    eb88f62 View commit details
    Browse the repository at this point in the history
  7. UsersScreen [nfc]: Inline handleFilterChange.

    Like we did in 4aedc4c.
    chrisbobbe committed Jul 27, 2021
    Configuration menu
    Copy the full SHA
    080b29f View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    4bc6dba View commit details
    Browse the repository at this point in the history
  9. AnimatedComponent [nfc]: Convert to function component.

    Use `useRef` for `animatedValue` [1] [2].
    
    Greg points out that we should choose `useEffect` over
    `useLayoutEffect` [3].
    
    [1] https://reactjs.org/docs/hooks-faq.html#is-there-something-like-instance-variables
    [2] https://reactnative.dev/docs/animated
    [3] zulip#4914 (comment)
    chrisbobbe committed Jul 27, 2021
    Configuration menu
    Copy the full SHA
    9daafd2 View commit details
    Browse the repository at this point in the history

Commits on Jul 28, 2021

  1. AnimatedComponent [nfc]: Initialize animatedValue based on visible.

    Currently, AnimatedComponent has only one caller, and it always
    starts by passing `false` for `visible`. Since it never passes
    `true` initially, the new path isn't exercised. But we should make
    it so future callers that pass `true` initially will actually see
    the element start as visible. So, do that.
    
    See more discussion at
      zulip#4914 (comment).
    chrisbobbe committed Jul 28, 2021
    Configuration menu
    Copy the full SHA
    f92460c View commit details
    Browse the repository at this point in the history
  2. AnimatedComponent [nfc]: Dedupe target-value expression.

    It's intentional that both of these expressions do the same thing:
    the point is that when the component first renders, it should start
    out in the desired state, and then when the desired state changes
    and causes a rerender it'll animate to the new desired state.
    
    So, we can make that explicit (and avoid some future change causing
    an accidental discrepancy) by writing the expression just once.
    
    Also because `visible` is already boolean, we can skip the `=== true`.
    gnprice committed Jul 28, 2021
    Configuration menu
    Copy the full SHA
    c7be42f View commit details
    Browse the repository at this point in the history
  3. AnimatedComponent: Only call animate on visibility change.

    Instead of on every render, where it often ends up being unnecessary
    work.
    chrisbobbe authored and gnprice committed Jul 28, 2021
    Configuration menu
    Copy the full SHA
    85d522d View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    1176105 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    786b190 View commit details
    Browse the repository at this point in the history
  6. Input [nfc]: Pull out componentStyles.

    chrisbobbe authored and gnprice committed Jul 28, 2021
    Configuration menu
    Copy the full SHA
    cc682d0 View commit details
    Browse the repository at this point in the history
  7. Input [nfc]: Convert to function component.

    Using `useContext(TranslationContext)` for the `GetText` function,
    instead of `withGetText`. (Since this is now a function component,
    we can subscribe to two different contexts, the other one being
    `ThemeContext`.)
    chrisbobbe authored and gnprice committed Jul 28, 2021
    Configuration menu
    Copy the full SHA
    32187e9 View commit details
    Browse the repository at this point in the history
  8. InputWithClearButton [nfc]: Remove unnecessary canBeCleared state.

    Greg points out [1] that `canBeCleared` is always the same as
    `text.length > 0`. So, just drop this piece of state and compute the
    value we need when we need it.
    
    [1] zulip#4914 (comment)
    chrisbobbe authored and gnprice committed Jul 28, 2021
    Configuration menu
    Copy the full SHA
    6498bb0 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    c8776e4 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    c1a3c51 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    726bb5d View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    5db4b92 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    f51bc79 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    ea65f05 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    45dc89c View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    a421ed6 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    91145ed View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    09e7077 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    a7d1087 View commit details
    Browse the repository at this point in the history
  20. SmartUrlInput [nfc]: Convert to function component.

    Using `useRef` for `unsubscribeFocusListener` [1]. We'll simplify
    the navigation-focus logic with `useFocusEffect` in the next commit.
    
    [1] https://reactjs.org/docs/hooks-faq.html#is-there-something-like-instance-variables
    chrisbobbe authored and gnprice committed Jul 28, 2021
    Configuration menu
    Copy the full SHA
    12bec80 View commit details
    Browse the repository at this point in the history
  21. SmartUrlInput: Use useFocusEffect.

    Following the doc at
      https://reactnavigation.org/docs/use-focus-effect/.
    
    Greg points out [1] that `useFocusEffect` seems to have the effect
    of calling the callback even on the component's first mount (if the
    screen is focused), whereas the old listener-based code would not.
    That doesn't seem to have a practical effect, here; empirically, it
    looks like the input gets focused anyway before this change. That's
    probably due to the `autoFocus` prop we pass to the `TextInput`.
    
    [1] zulip#4914 (comment).
    chrisbobbe authored and gnprice committed Jul 28, 2021
    Configuration menu
    Copy the full SHA
    3f9cd6c View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    9effeaf View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    0b01c9e View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    34eb383 View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    e2b23ce View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    d3f610f View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    a2f9ca9 View commit details
    Browse the repository at this point in the history
  28. Configuration menu
    Copy the full SHA
    a66b701 View commit details
    Browse the repository at this point in the history
  29. Configuration menu
    Copy the full SHA
    a0d5cb7 View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    2a55fba View commit details
    Browse the repository at this point in the history
  31. Configuration menu
    Copy the full SHA
    6650e6e View commit details
    Browse the repository at this point in the history
  32. flow: Annotate some more exported React components.

    This is much easier to do now that we've converted these to function
    components in this series.
    
    This will help move us along toward Flow's new "Types-First" mode;
    switching entirely is zulip#4907.
    
    Prefer the `Node` type exported from React over `React$Node`.
    They're equivalent, but Greg prefers `Node` as it seems cleaner; see
      https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/Flow.20types-first/near/1239060.
    chrisbobbe authored and gnprice committed Jul 28, 2021
    Configuration menu
    Copy the full SHA
    81a50bb View commit details
    Browse the repository at this point in the history