warn about PureComponent in docs

Reviewed By: hramos

Differential Revision: D4663872

fbshipit-source-id: cb2bd2a2d588a9419da7517304d0612e259151e3
This commit is contained in:
Spencer Ahrens 2017-03-06 19:20:20 -08:00 committed by Facebook Github Bot
parent 3f6476fc5e
commit 293bb36c0e
3 changed files with 15 additions and 3 deletions

View File

@ -179,12 +179,16 @@ type DefaultProps = typeof defaultProps;
* *
* - Internal state is not preserved when content scrolls out of the render window. Make sure all * - Internal state is not preserved when content scrolls out of the render window. Make sure all
* your data is captured in the item data or external stores like Flux, Redux, or Relay. * your data is captured in the item data or external stores like Flux, Redux, or Relay.
* - This is a `PureComponent` which means that it will not re-render if `props` remain shallow-
* equal. Make sure that everything your `renderItem` function depends on is passed as a prop that
* is not `===` after updates, otherwise your UI may not update on changes. This includes the
* `data` prop and parent component state.
* - In order to constrain memory and enable smooth scrolling, content is rendered asynchronously * - In order to constrain memory and enable smooth scrolling, content is rendered asynchronously
* offscreen. This means it's possible to scroll faster than the fill rate ands momentarily see * offscreen. This means it's possible to scroll faster than the fill rate ands momentarily see
* blank content. This is a tradeoff that can be adjusted to suit the needs of each application, * blank content. This is a tradeoff that can be adjusted to suit the needs of each application,
* and we are working on improving it behind the scenes. * and we are working on improving it behind the scenes.
* - By default, the list looks for a `key` prop on each item and uses that for the React key. * - By default, the list looks for a `key` prop on each item and uses that for the React key.
* Alternatively, you can provide a custom keyExtractor prop. * Alternatively, you can provide a custom `keyExtractor` prop.
*/ */
class FlatList<ItemT> extends React.PureComponent<DefaultProps, Props<ItemT>, void> { class FlatList<ItemT> extends React.PureComponent<DefaultProps, Props<ItemT>, void> {
static defaultProps: DefaultProps = defaultProps; static defaultProps: DefaultProps = defaultProps;

View File

@ -165,12 +165,16 @@ type DefaultProps = typeof VirtualizedSectionList.defaultProps;
* *
* - Internal state is not preserved when content scrolls out of the render window. Make sure all * - Internal state is not preserved when content scrolls out of the render window. Make sure all
* your data is captured in the item data or external stores like Flux, Redux, or Relay. * your data is captured in the item data or external stores like Flux, Redux, or Relay.
* - This is a `PureComponent` which means that it will not re-render if `props` remain shallow-
* equal. Make sure that everything your `renderItem` function depends on is passed as a prop that
* is not `===` after updates, otherwise your UI may not update on changes. This includes the
* `data` prop and parent component state.
* - In order to constrain memory and enable smooth scrolling, content is rendered asynchronously * - In order to constrain memory and enable smooth scrolling, content is rendered asynchronously
* offscreen. This means it's possible to scroll faster than the fill rate ands momentarily see * offscreen. This means it's possible to scroll faster than the fill rate ands momentarily see
* blank content. This is a tradeoff that can be adjusted to suit the needs of each application, * blank content. This is a tradeoff that can be adjusted to suit the needs of each application,
* and we are working on improving it behind the scenes. * and we are working on improving it behind the scenes.
* - By default, the list looks for a `key` prop on each item and uses that for the React key. * - By default, the list looks for a `key` prop on each item and uses that for the React key.
* Alternatively, you can provide a custom keyExtractor prop. * Alternatively, you can provide a custom `keyExtractor` prop.
*/ */
class SectionList<SectionT: SectionBase<any>> class SectionList<SectionT: SectionBase<any>>
extends React.PureComponent<DefaultProps, Props<SectionT>, void> extends React.PureComponent<DefaultProps, Props<SectionT>, void>

View File

@ -163,12 +163,16 @@ type State = {first: number, last: number};
* *
* - Internal state is not preserved when content scrolls out of the render window. Make sure all * - Internal state is not preserved when content scrolls out of the render window. Make sure all
* your data is captured in the item data or external stores like Flux, Redux, or Relay. * your data is captured in the item data or external stores like Flux, Redux, or Relay.
* - This is a `PureComponent` which means that it will not re-render if `props` remain shallow-
* equal. Make sure that everything your `renderItem` function depends on is passed as a prop that
* is not `===` after updates, otherwise your UI may not update on changes. This includes the
* `data` prop and parent component state.
* - In order to constrain memory and enable smooth scrolling, content is rendered asynchronously * - In order to constrain memory and enable smooth scrolling, content is rendered asynchronously
* offscreen. This means it's possible to scroll faster than the fill rate ands momentarily see * offscreen. This means it's possible to scroll faster than the fill rate ands momentarily see
* blank content. This is a tradeoff that can be adjusted to suit the needs of each application, * blank content. This is a tradeoff that can be adjusted to suit the needs of each application,
* and we are working on improving it behind the scenes. * and we are working on improving it behind the scenes.
* - By default, the list looks for a `key` prop on each item and uses that for the React key. * - By default, the list looks for a `key` prop on each item and uses that for the React key.
* Alternatively, you can provide a custom keyExtractor prop. * Alternatively, you can provide a custom `keyExtractor` prop.
* *
* NOTE: `LayoutAnimation` and sticky section headers both have bugs when used with this and are * NOTE: `LayoutAnimation` and sticky section headers both have bugs when used with this and are
* therefore not officially supported yet. * therefore not officially supported yet.