mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
Merge pull request #12590 from Chudesnov/stateless-components-children
Allow children in stateless components’ props by default
This commit is contained in:
Vendored
+1
-1
@@ -201,7 +201,7 @@ declare namespace React {
|
||||
|
||||
type SFC<P> = StatelessComponent<P>;
|
||||
interface StatelessComponent<P> {
|
||||
(props: P, context?: any): ReactElement<any>;
|
||||
(props: P & { children?: ReactNode }, context?: any): ReactElement<any>;
|
||||
propTypes?: ValidationMap<P>;
|
||||
contextTypes?: ValidationMap<any>;
|
||||
defaultProps?: P;
|
||||
|
||||
@@ -152,6 +152,10 @@ StatelessComponent2.defaultProps = {
|
||||
foo: 42
|
||||
};
|
||||
|
||||
var StatelessComponent3: React.SFC<SCProps> =
|
||||
// allows usage of props.children
|
||||
props => React.DOM.div(null, props.foo, props.children);
|
||||
|
||||
// React.createFactory
|
||||
var factory: React.CFactory<Props, ModernComponent> =
|
||||
React.createFactory(ModernComponent);
|
||||
|
||||
@@ -13,3 +13,13 @@ StatelessComponent.defaultProps = {
|
||||
};
|
||||
|
||||
<StatelessComponent />;
|
||||
|
||||
var StatelessComponent2: React.SFC<SCProps> = ({ foo, children }) => {
|
||||
return <div>{ foo }{ children }</div>;
|
||||
};
|
||||
StatelessComponent2.displayName = "StatelessComponent4";
|
||||
StatelessComponent2.defaultProps = {
|
||||
foo: 42
|
||||
};
|
||||
|
||||
<StatelessComponent2>24</StatelessComponent2>;
|
||||
|
||||
Reference in New Issue
Block a user