From 236bb018ab1b0496113d0632d7dba428140a8a70 Mon Sep 17 00:00:00 2001 From: Richard Cann Date: Thu, 27 Sep 2018 11:11:49 -0700 Subject: [PATCH] StaticRenderer: Removed prop types (#21348) Summary: related #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: https://github.com/facebook/react-native/pull/21348 Differential Revision: D10084990 Pulled By: TheSavior fbshipit-source-id: a87a8d4976c6ffaf83dc0fddc758869dbc2e2803 --- Libraries/Components/StaticRenderer.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Libraries/Components/StaticRenderer.js b/Libraries/Components/StaticRenderer.js index eecf3b630..f4d630d6a 100644 --- a/Libraries/Components/StaticRenderer.js +++ b/Libraries/Components/StaticRenderer.js @@ -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 { + shouldComponentUpdate(nextProps: Props): boolean { return nextProps.shouldUpdate; }