Skip to content

Commit

Permalink
StaticRenderer: Removed prop types (facebook#21348)
Browse files Browse the repository at this point in the history
Summary:
related facebook#21342

 The `render` function, I was not able to specifically type since the props passed to it may vary. At the moment only `renderRow` function from ListView component is using StaticRenderer, and the type of the renderRow function is `Function`.
Let me know what your thoughts are on this. Thank you
Pull Request resolved: facebook#21348

Differential Revision: D10084990

Pulled By: TheSavior

fbshipit-source-id: a87a8d4976c6ffaf83dc0fddc758869dbc2e2803
  • Loading branch information
richardcann authored and facebook-github-bot committed Sep 27, 2018
1 parent 0bce941 commit 3cd271e
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions Libraries/Components/StaticRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@

const React = require('React');

const PropTypes = require('prop-types');

class StaticRenderer extends React.Component<{
type Props = $ReadOnly<{|
/**
* Indicates whether the render function needs to be called again
*/
shouldUpdate: boolean,
render: Function,
}> {
static propTypes = {
shouldUpdate: PropTypes.bool.isRequired,
render: PropTypes.func.isRequired,
};
/**
* () => renderable
* A function that returns a renderable component
*/
render: () => React.Node,
|}>;

shouldComponentUpdate(nextProps: {shouldUpdate: boolean}): boolean {
class StaticRenderer extends React.Component<Props> {
shouldComponentUpdate(nextProps: Props): boolean {
return nextProps.shouldUpdate;
}

Expand Down

0 comments on commit 3cd271e

Please sign in to comment.