2015-01-29 17:10:49 -08:00
|
|
|
/**
|
2018-09-11 15:27:47 -07:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2015-03-23 15:07:33 -07:00
|
|
|
*
|
2018-02-16 18:24:55 -08:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2015-01-29 17:10:49 -08:00
|
|
|
*
|
2018-05-10 19:06:46 -07:00
|
|
|
* @format
|
2015-03-25 15:36:50 -07:00
|
|
|
* @flow
|
2015-01-29 17:10:49 -08:00
|
|
|
*/
|
2018-05-10 19:06:46 -07:00
|
|
|
|
2015-01-29 17:10:49 -08:00
|
|
|
'use strict';
|
|
|
|
|
2018-03-03 15:04:46 -08:00
|
|
|
const React = require('React');
|
2015-01-29 17:10:49 -08:00
|
|
|
|
2018-09-27 11:11:49 -07:00
|
|
|
type Props = $ReadOnly<{|
|
|
|
|
/**
|
|
|
|
* Indicates whether the render function needs to be called again
|
|
|
|
*/
|
2017-08-17 18:36:54 -07:00
|
|
|
shouldUpdate: boolean,
|
2018-09-27 11:11:49 -07:00
|
|
|
/**
|
|
|
|
* () => renderable
|
|
|
|
* A function that returns a renderable component
|
|
|
|
*/
|
|
|
|
render: () => React.Node,
|
|
|
|
|}>;
|
2015-01-29 17:10:49 -08:00
|
|
|
|
2018-09-27 11:11:49 -07:00
|
|
|
class StaticRenderer extends React.Component<Props> {
|
|
|
|
shouldComponentUpdate(nextProps: Props): boolean {
|
2015-01-29 17:10:49 -08:00
|
|
|
return nextProps.shouldUpdate;
|
2016-07-26 01:00:02 -07:00
|
|
|
}
|
2015-01-29 17:10:49 -08:00
|
|
|
|
2017-08-17 18:36:54 -07:00
|
|
|
render(): React.Node {
|
2015-01-29 17:10:49 -08:00
|
|
|
return this.props.render();
|
2016-07-26 01:00:02 -07:00
|
|
|
}
|
|
|
|
}
|
2015-01-29 17:10:49 -08:00
|
|
|
|
|
|
|
module.exports = StaticRenderer;
|