mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
This removes the remaining `propTypes` validation calls, making
declaring `propTypes` a no-op. In other words, React itself will no
longer validate the `propTypes` that you declare on your components.
In general, our recommendation is to use static type checking (e.g.
TypeScript). If you'd like to still run propTypes checks, you can do so
manually, same as you'd do outside React:
```js
import checkPropTypes from 'prop-types/checkPropTypes';
function Button(props) {
checkPropTypes(Button.propTypes, prop, 'prop', Button.name)
// ...
}
```
This could be automated as a Babel plugin if you want to keep these
checks implicit. (We will not be providing such a plugin, but someone in
community might be interested in building or maintaining one.)
49 lines
1.0 KiB
JavaScript
49 lines
1.0 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
* @typechecks
|
|
*
|
|
* Example usage:
|
|
* <Circle
|
|
* radius={10}
|
|
* stroke="green"
|
|
* strokeWidth={3}
|
|
* fill="blue"
|
|
* />
|
|
*
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
var assign = Object.assign;
|
|
var React = require('react');
|
|
var ReactART = require('react-art');
|
|
|
|
var createReactClass = require('create-react-class');
|
|
|
|
var Path = ReactART.Path;
|
|
var Shape = ReactART.Shape;
|
|
|
|
/**
|
|
* Circle is a React component for drawing circles. Like other ReactART
|
|
* components, it must be used in a <Surface>.
|
|
*/
|
|
var Circle = createReactClass({
|
|
displayName: 'Circle',
|
|
|
|
render: function render() {
|
|
var radius = this.props.radius;
|
|
|
|
var path = Path()
|
|
.moveTo(0, -radius)
|
|
.arc(0, radius * 2, radius)
|
|
.arc(0, radius * -2, radius)
|
|
.close();
|
|
return React.createElement(Shape, assign({}, this.props, {d: path}));
|
|
},
|
|
});
|
|
|
|
module.exports = Circle;
|