You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ChatScreen: Switch to new React Context API for theme colors.
Per #1946, we're moving to the new React Context API
(https://reactjs.org/docs/context.html).
As in the parent commit, for Screen, separate the constant parts of
the style from those that change with the theme; the latter get
computed in the render method.
Differing from the parent commit, put the constant parts of the
style in an instance field, rather than an outer-level `const`
declaration. We haven't settled the question universally; in
discussion [1], Greg points out,
"""
There's a tension between two things that are good to have:
* The render method, particularly the blob of JSX that's typically
found all at the end, is where we describe the visual look of the
component. It'd be good for the description of its visual look to be
all in one place, or at least reasonably close together, and the
styles are part of that.
* The styles are often kind of long with a lot of fairly boring
stuff, and it's good to be able to see all the other stuff going on
in `render` -- often including logic about what to show at all, or
what data to use -- without the more boring of the styles details
pushing it off the screen.
"""
Putting it an instance property means it's closer at hand than at a
`const` above the class definition, so, slightly favor that pattern
by using it in this file, where there's no precedent (or there was a
precedent, and it was recently removed in 8621b61, before this
series of commits).
[1]: https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/Styles.20in.20component.20files/near/860528
0 commit comments