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

[RFR] Declare fetch side effects as function #3425

Merged
merged 5 commits into from
Jul 22, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Review
fzaninotto committed Jul 22, 2019
commit 55c8e0663e97b11aa8144a8c7aee84e81ba49054
2 changes: 1 addition & 1 deletion docs/Actions.md
Original file line number Diff line number Diff line change
@@ -230,7 +230,7 @@ const ApproveButton = ({ record }) => {
};
```

The `onSuccess` function is called with the response from the `dataProvider` as argument. The `onError` function is called wit hthe error returned by the `dataProvider`.
The `onSuccess` function is called with the response from the `dataProvider` as argument. The `onError` function is called with the error returned by the `dataProvider`.

React-admin provides the following hooks to handle most common side effects:

2 changes: 1 addition & 1 deletion examples/simple/src/users/UserEdit.js
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ const UserEditToolbar = props => {
return (
<Toolbar {...props} classes={classes}>
<SaveButton />
<DeleteWithConfirmButton {...props} />
<DeleteWithConfirmButton />
</Toolbar>
);
};
3 changes: 2 additions & 1 deletion packages/ra-core/src/fetch/useDelete.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,8 @@ import useMutation from './useMutation';
import { Identifier } from '../types';

/**
* Get a callback to call the dataProvider with a DELETE verb, the result and the loading state.
* Get a callback to call the dataProvider with a DELETE verb, the result
* of the call (the deleted record), and the loading state.
*
* The return value updates according to the request state:
*
Original file line number Diff line number Diff line change
@@ -144,7 +144,7 @@ DeleteWithConfirmButton.propTypes = {
PropTypes.bool,
PropTypes.func,
]),
resource: PropTypes.string.isRequired,
resource: PropTypes.string,
icon: PropTypes.element,
};

Original file line number Diff line number Diff line change
@@ -107,7 +107,7 @@ DeleteWithUndoButton.propTypes = {
PropTypes.bool,
PropTypes.func,
]),
resource: PropTypes.string.isRequired,
resource: PropTypes.string,
icon: PropTypes.element,
};