Sha256: 93b906e38bd5c976d9399936d44dde9d5051e285e5f60b4f204de49510205354
Contents?: true
Size: 783 Bytes
Versions: 48
Compression:
Stored size: 783 Bytes
Contents
import React, { useEffect, useRef } from 'react'; export const withRenderHandler = ({ Component }) => componentProps => ( <Component {...componentProps} /> ); export const callOnMount = callback => WrappedComponent => componentProps => { callback(componentProps); return <WrappedComponent {...componentProps} />; }; export const callOnPopState = callback => WrappedComponent => componentProps => { const didMount = useRef(false); const { history: { action, location: { search }, }, } = componentProps; useEffect(() => { if (action === 'POP' && didMount.current) { callback(componentProps); } else { didMount.current = true; } }, [search, action, componentProps]); return <WrappedComponent {...componentProps} />; };
Version data entries
48 entries across 48 versions & 3 rubygems