// Server Side Component compatibility (specifying this cannot be used as such) // https://beta.nextjs.org/docs/rendering/server-and-client-components#third-party-packages 'use client'; import { useEffect, useState } from 'react'; export default function DevToolsButton({ pos, }: { pos: DevToolsPosition | null | undefined; }) { // do not fail hydration with SSR - this is client only const [enable, setEnable] = useState(false); useEffect(() => { if ( typeof window !== 'undefined' && (window as any).__REDUX_DEVTOOLS_EXTENSION__ ) setEnable(true); }, []); if (!enable || !pos) return null; return (
DevTools{' '} ℹ️
(window as any).__REDUX_DEVTOOLS_EXTENSION__.open('panel') } />
); } export type DevToolsPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'; const PosToStyle: Record = { 'bottom-right': { bottom: '10px', right: '10px' }, 'bottom-left': { bottom: '10px', left: '10px' }, 'top-right': { top: '10px', right: '10px' }, 'top-left': { top: '10px', left: '10px' }, };