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

Change AutoItems interface #58

Open
1 task done
yoavaa opened this issue Apr 5, 2022 · 1 comment
Open
1 task done

Change AutoItems interface #58

yoavaa opened this issue Apr 5, 2022 · 1 comment
Labels
feature-request New feature or request

Comments

@yoavaa
Copy link
Collaborator

yoavaa commented Apr 5, 2022

Is there an existing issue for this?

  • Yes, I have searched the existing issues

The problem

AutoItems props are defined as

export type AutoItemsProps = {
    render?(
        item: React.ReactNode,
        props: AutoViewProps,
        index: number
    ): React.ReactNode;
} & AutoViewProps;

which forces to provide render as a prop in JSX, as

<AutoItems {...props} render={
    (node) => <li>node</li>
}>
</AutoItems>

Describe the solution you'd like

I suggest to change the interface a bit, renaming render to children, so that

export interface AutoItemsProps extends AutoViewProps {
    render?(
        item: React.ReactNode,
        props: AutoViewProps,
        index: number
    ): React.ReactNode;
}

which allows

<AutoItems {...props}>
    {(node) => <li>node</li>}
</AutoItems>

and still allows using

<AutoItems {...props}/>

Basically, using a property named children allows to place the function as a child in the JSX

Describe alternatives you've considered

No response

@yoavaa yoavaa added the feature-request New feature or request label Apr 5, 2022
@yoavaa
Copy link
Collaborator Author

yoavaa commented Apr 5, 2022

Same issue for AutoFields

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant