Last active
August 19, 2021 03:23
-
-
Save dalmo3/a30eea145484fae8d5360fc79150fb20 to your computer and use it in GitHub Desktop.
React admin custom toolbar with redirect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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