Skip to content

Commit eccd538

Browse files
committed
Update to no longer use ReactDom
This solves that issue that a ton of people were having with the something went wrong error
1 parent 17b2a16 commit eccd538

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

packages/marketplace/src/components/TabBar.tsx

+21-24
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,6 @@ const TabBarMore = React.memo<TabBarMoreProps>(
6262
},
6363
);
6464

65-
const TabBarContext = ({ children }) => {
66-
if (!children || !document.querySelector(".main-topBar-topbarContentWrapper") ) return null;
67-
return ReactDOM.createPortal(
68-
<div className="main-topBar-topbarContent">
69-
{children}
70-
</div>,
71-
document.querySelector(".main-topBar-topbarContentWrapper") as Element,
72-
);
73-
};
74-
75-
TabBarContext.propTypes = {
76-
children: PropTypes.element,
77-
};
78-
7965
export const TopBarContent = (props: {
8066
links: TabItemConfig[];
8167
activeLink: string;
@@ -86,24 +72,35 @@ export const TopBarContent = (props: {
8672

8773
const [windowSize, setWindowSize] = useState(resizeHost.clientWidth);
8874
const resizeHandler = () => setWindowSize(resizeHost.clientWidth);
89-
75+
const contextHandler = () => {
76+
// Move the marketplace-tabBar item to the main-topBar-topbarContent div
77+
const tabBar = document.querySelector(".marketplace-tabBar");
78+
const topBarContent = document.querySelector(".main-topBar-container");
79+
console.log(tabBar, topBarContent);
80+
if (tabBar && topBarContent) {
81+
topBarContent.appendChild(tabBar);
82+
}
83+
84+
};
9085
useEffect(() => {
9186
const observer = new ResizeObserver(resizeHandler);
9287
observer.observe(resizeHost);
9388
return () => {
9489
observer.disconnect();
9590
};
9691
}, [resizeHandler]);
97-
92+
useEffect(()=>{
93+
contextHandler();
94+
});
9895
return (
99-
<TabBarContext>
100-
<TabBar
101-
windowSize={windowSize}
102-
links={props.links}
103-
activeLink={props.activeLink}
104-
switchCallback={props.switchCallback}
105-
/>
106-
</TabBarContext>
96+
97+
<TabBar
98+
windowSize={windowSize}
99+
links={props.links}
100+
activeLink={props.activeLink}
101+
switchCallback={props.switchCallback}
102+
/>
103+
107104
);
108105
};
109106

0 commit comments

Comments
 (0)