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

[Doc] Fix Edit Toolbar docs to explain how to use a CreateButton #4544

Merged
merged 3 commits into from
Mar 24, 2020

Conversation

agent3bood
Copy link
Contributor

@@ -883,6 +883,8 @@ Here are the props received by the `Toolbar` component when passed as the `toolb

**Tip**: To alter the form values before submitting, you should use the `handleSubmit` prop. See [Altering the Form Values before Submitting](#altering-the-form-values-before-submitting) for more information and examples.

**Tip** `<Toolbar>` will pass many props to its children, if you use `<CreateButton>` or other buttons you will get `React does not recognize the <xxx> prop on a DOM element` errors, insteade you can build you own button.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are several things wrong in that change

<Toolbar> will pass many props to its children

Is vague, uses future tense while we try to use present tense everywhere

if you use <CreateButton> or other buttons

Not true: EditButton or DeleteButton don't trigger the error

insteade

isn't English

you can build you own button

This isn't clear at all. And besides, the recommendation is rather to wrap an existing button inside another component that will just use the necessary props and drop the rest

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated my PR, now it is specific and has example

@fzaninotto fzaninotto changed the title Update Toolbar docs (usage of buttons) Fix Edit Toolbar docs to explain how to use a CreateButton Mar 24, 2020
@fzaninotto fzaninotto merged commit 026b989 into marmelab:master Mar 24, 2020
@fzaninotto
Copy link
Member

Thanks.

@fzaninotto fzaninotto added this to the 3.3.3 milestone Mar 24, 2020
@fzaninotto fzaninotto changed the title Fix Edit Toolbar docs to explain how to use a CreateButton [Doc] Fix Edit Toolbar docs to explain how to use a CreateButton Mar 24, 2020
@WiXSL
Copy link
Contributor

WiXSL commented Mar 24, 2020

Couldn't this be improved in CreateButton.tsx by sanitising this props?
This is done in CloneButton and DeleteButton.

In fact this problem happens in <Button/> component which is used by all the other type of buttons. The code can be refactored so only this component gets sanitized.

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

Successfully merging this pull request may close these issues.

None yet

3 participants