Given the following code using PropTypes (see this question )
const SomeComponent = ({comp}) => {...} SomeComponent.propTypes = { comp: PropTypes.shape({ type: PropTypes.oneOf([SomeOtherComponent]) }) }
what is equivalent using stream types?
I just got to:
const SomeComponent = ({comp}: {comp: React$Element<any>}) => {...}
using this for reference, but it will allow to compbe any component of React.
comp
How can I check the prop type to make sure it is an instance of a specific React component using Flow?
Like stream 0.53, this can be done using React.Element<typeof Component>.
React.Element<typeof Component>
: . , Flow , , , React . , , , . Flow , , , Flow .
, , . , , " ". :
function elementIsOfType(element, typeName) { if (!__DEV__) { return true; } return element.type.displayName === typeName; }
__DEV__ false, .
__DEV__
false
Source: https://habr.com/ru/post/1676092/More articles:Parsing the source string with embedded quotes in a list with lua - luaHow can I enter two different files in Log4perl? - perljava.lang.NoClassDefFoundError: failed to initialize class hudson.util.ProcessTree $ UnixReflection - javanode -canvas works in Node, but crashes if necessary from PhantomJS - javascriptHow to correctly import Tensorflow source codes using Clion or Netbeans - c ++How to set readable characters in a marine facet grid? - pythonСортировка массива объектов на основе ключа и на основе значения - javascriptCan I reference the .NetStandard library from my application for Windows 10 UWP? - c #How to compress pdf using node? - node.jsSequential row sizes in QGridLayout - c ++All Articles