Remove bootstrap when unmounting ctb

Signed-off-by: soupette <cyril@strapi.io>
This commit is contained in:
soupette 2021-09-29 06:22:43 +02:00
parent 4b404f43f6
commit 7d718c7583

View File

@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect } from 'react';
import { ThemeProvider } from 'styled-components';
import 'bootstrap/dist/css/bootstrap.css';
@ -92,6 +92,21 @@ const theme = {
};
// eslint-disable-next-line react/prop-types
const TempTP = ({ children }) => <ThemeProvider theme={theme}>{children}</ThemeProvider>;
const TempTP = ({ children }) => {
// FIXME:
// temporary hack to remove bootstrap css
// tested on chrome, safari and firefox it seems to be working...
useEffect(() => {
return () => {
const targetelement = 'style';
const allsuspects = document.getElementsByTagName(targetelement);
document.getElementsByTagName('head')[0].removeChild(allsuspects[allsuspects.length - 1]);
};
}, []);
return <ThemeProvider theme={theme}>{children}</ThemeProvider>;
};
export default TempTP;