chore(eslint): fix flash message root element query
This commit is contained in:
parent
68e89af775
commit
95b9e47993
1 changed files with 4 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { createPortal } from 'react-dom';
|
import { createPortal } from 'react-dom';
|
||||||
|
import invariant from 'tiny-invariant';
|
||||||
|
|
||||||
export function FlashMessage({
|
export function FlashMessage({
|
||||||
message,
|
message,
|
||||||
|
@ -12,11 +13,13 @@ export function FlashMessage({
|
||||||
sticky?: boolean;
|
sticky?: boolean;
|
||||||
fixed?: boolean;
|
fixed?: boolean;
|
||||||
}) {
|
}) {
|
||||||
|
const element = document.getElementById('flash_messages');
|
||||||
|
invariant(element, 'Flash messages root element not found');
|
||||||
return createPortal(
|
return createPortal(
|
||||||
<div className="flash_message center">
|
<div className="flash_message center">
|
||||||
<div className={flashClassName(level, sticky, fixed)}>{message}</div>
|
<div className={flashClassName(level, sticky, fixed)}>{message}</div>
|
||||||
</div>,
|
</div>,
|
||||||
document.getElementById('flash_messages')!
|
element
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue