Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

required children prop #2218

Merged
merged 19 commits into from Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,12 @@
import React from 'react';
import { RequiredChildrenComponentProps } from "../props";


const RequiredChildrenComponent = (props: RequiredChildrenComponentProps) => {
const {children} = props;
siner308 marked this conversation as resolved.
Show resolved Hide resolved
return <div>
{children}
</div>
alexcjohnson marked this conversation as resolved.
Show resolved Hide resolved
}

export default RequiredChildrenComponent;
Expand Up @@ -6,6 +6,7 @@ import WrappedHTML from './components/WrappedHTML';
import FCComponent from './components/FCComponent';
import EmptyComponent from './components/EmptyComponent';
import MixedComponent from './components/MixedComponent';
import RequiredChildrenComponent from './components/RequiredChildrenComponent';

export {
TypeScriptComponent,
Expand All @@ -16,4 +17,5 @@ export {
FCComponent,
EmptyComponent,
MixedComponent,
RequiredChildrenComponent,
};
Expand Up @@ -48,3 +48,7 @@ export type WrappedHTMLProps = {
children?: React.ReactNode;
id?: string;
} & Pick<React.ButtonHTMLAttributes<any>, 'autoFocus'>

export type RequiredChildrenComponentProps = {
children: React.ReactNode;
}
8 changes: 8 additions & 0 deletions tests/integration/test_generation.py
Expand Up @@ -9,6 +9,7 @@
TypeScriptComponent,
TypeScriptClassComponent,
StandardComponent,
RequiredChildrenComponent,
)
from dash_test_components import StyledComponent
from dash.html import Button, Div
Expand Down Expand Up @@ -99,3 +100,10 @@ def test_gene003_max_props():

with pytest.raises(TypeError):
MyNestedComponent(valuey="nor this")


def test_gene004_required_children_prop():
with pytest.raises(TypeError):
RequiredChildrenComponent()

RequiredChildrenComponent(children='worked')