Skip to content

Instantly share code, notes, and snippets.

@dalmo3
Last active August 19, 2021 03:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dalmo3/a30eea145484fae8d5360fc79150fb20 to your computer and use it in GitHub Desktop.
Save dalmo3/a30eea145484fae8d5360fc79150fb20 to your computer and use it in GitHub Desktop.
React admin custom toolbar with redirect
// add a custom toolbar prop to both CommentEdit and CommentCreate
// don't use redirect prop!
<SimpleForm toolbar={<CommentFormToolbar/>}>
// defined as
const CommentFormToolbar: VFC<ToolbarProps> = (props) => {
const { post_id } = useRecordContext();
return (
<Toolbar {...props}>
<SaveButton redirect={`/posts/${post_id }/show`} />
<DeleteButton redirect={`/posts/${post_id }/show`} />
</Toolbar>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment