Don't try to be fancy, just pain
This commit is contained in:
parent
a966613890
commit
dd381f65a9
2 changed files with 7 additions and 29 deletions
|
@ -1,23 +0,0 @@
|
|||
import React from 'react';
|
||||
import useFlash from '@/plugins/useFlash';
|
||||
import { Actions } from 'easy-peasy';
|
||||
import { ApplicationStore } from '@/state';
|
||||
|
||||
export interface WithFlashProps {
|
||||
flash: Actions<ApplicationStore>['flashes'];
|
||||
}
|
||||
|
||||
function withFlash<TOwnProps> (Component: React.ComponentType<TOwnProps & WithFlashProps>): React.ComponentType<TOwnProps> {
|
||||
return (props: TOwnProps) => {
|
||||
const { addError, addFlash, clearFlashes, clearAndAddHttpError } = useFlash();
|
||||
|
||||
return (
|
||||
<Component
|
||||
flash={{ addError, addFlash, clearFlashes, clearAndAddHttpError }}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export default withFlash;
|
Reference in a new issue