Fixed purecomponent not updating

This commit is contained in:
keplyx 2020-03-10 16:43:52 +01:00
parent 38b1a158c8
commit a10d357d8f
2 changed files with 6 additions and 10 deletions

View file

@ -16,6 +16,7 @@ type Props = {
renderSectionHeader: React.Node,
stickyHeader: boolean,
createDataset: Function,
updateData: number,
}
type State = {
@ -28,19 +29,15 @@ type State = {
const MIN_REFRESH_TIME = 5 * 1000;
/**
* Custom component defining a material icon using native base
*
* @prop active {boolean} Whether to set the icon color to active
* @prop icon {string} The icon string to use from MaterialCommunityIcons
* @prop color {string} The icon color. Use default theme color if unspecified
* @prop fontSize {number} The icon size. Use 26 if unspecified
* @prop width {number} The icon width. Use 30 if unspecified
* This is a pure component, meaning it will only update if a shallow comparison of state and props is different.
* To force the component to update, change the value of updateData.
*/
export default class WebSectionList extends React.PureComponent<Props, State> {
static defaultProps = {
renderSectionHeader: null,
stickyHeader: false,
updateData: null,
};
webDataManager: WebDataManager;
@ -88,8 +85,6 @@ export default class WebSectionList extends React.PureComponent<Props, State> {
this.onRefresh();
}
/**
* Refresh data when focusing the screen and setup a refresh interval if asked to
*/

View file

@ -464,7 +464,8 @@ class ProxiwashScreen extends React.Component<Props, State> {
renderItem={this.getRenderItem}
renderSectionHeader={this.getRenderSectionHeader}
autoRefreshTime={REFRESH_TIME}
refreshOnFocus={true}/>
refreshOnFocus={true}
updateData={this.state.machinesWatched.length}/>
</View>
);