import React , { useEffect } from 'react' ; import { connect } from 'react-redux' ; import { bindActionCreators , Dispatch } from 'redux' ; import { specParsed , specUnmounted } from '../state/actions/specs' ; const SpecsParserComponent = ( props ) => { const injected = props as DispatchProps ; useEffect ( ( ) => { injected . specParsed ( ) ; } ) ; useEffect ( ( ) => ( ) => { injected . specUnmounted ( ) ; } , [ ] ) ; return props . children ? ( props . children as React . ReactElement ) : null ; } ; interface DispatchProps { specParsed : ( ) => void ; specUnmounted : ( ) => void ; } const mapDispatchToProps = ( dispatch ) : DispatchProps => bindActionCreators ( { specParsed , specUnmounted , } , dispatch ) ; internal export const SpecsParser = connect ( null , mapDispatchToProps ) ( SpecsParserComponent ) ;