Hi, I am learning react by video tutorial and I have issue with PropTypes.
If I remove title or subtitle from this: <TitleBar title="Test title"/>
The code still works normal without warrnings in console even if it’s required.
import React from 'react';
import PropTypes from 'prop-types';
export default class TitleBar extends React.Component {
render(){
return (
<div>
<h1>{this.props.title}</h1>
</div>
);
}
}
TitleBar.propTypes = {
title: PropTypes.string.isRequired
};
I also tired to copy/paste official Meteor React tutorial and I got the same problem.
It looks like propTypes don’t effect TitleBar class at all.
What is the purpose of PropTypes if doesn’t do nothing?
If I set it to bool or array it should show warnings in the console, but it doesn’t do nothing.
Or If I remove “task={task}” it should also show warning.
This is very frustrating, If even official tutorials don’t work as expected.