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
Screen: Switch to new React Context API for theme colors.
Per zulip#1946, we're moving to the new React Context API
(https://reactjs.org/docs/context.html).
For details like height, margin, and flex that are about the
component and not the theme, put these in the existing
`componentStyles` object.
A functional difference between this pattern and the one in, e.g.,
a2bfcb4 and 51dd1b3, is that, here, we don't group the
theme-dependent styles together with the constant ones. If we don't
compute the theme-dependent styles in the `render` method, then the
component's appearance won't live-update when the theme is changed.
A universal choice between the non-functional difference between
using an instance field and an outer-level `const` declaration
hasn't been made, but there's been some fruitful discussion [1],
quoted in the next commit. Here, we just go with the existing
`const` declaration.
In practice, the lack of live-updating has probably never been
observed, as a side-effect of the `key={theme}` hack in
src/boot/StylesProvider.js, which causes most of the entire tree to
be remounted (not rerendered, remounted) when the theme changes.
This hack is explained in docs/architecture/react.md#context, and it
will be removed at the end of this series of commits, since the new
Context API makes it unnecessary. Before that happens, the latent
bugs in a2bfcb4 and 51dd1b3 (mentioned above), and elsewhere,
will be fixed.
[1]: https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/Styles.20in.20component.20files/near/860528
0 commit comments