import React, {useState, useCallback, useEffect} from 'react' import {Transition, animated} from 'react-spring/renderprops' import styled, { } from 'styled-components' import BookComponentsController from './BookComponentsController' const ComponentContainer = styled.div` display: flex; flex-direction: column; overflowY: hidden; align-items: center; ` const PageContainer = styled.div` height: 600px; position: relative; width: 100%; cursor: pointer; margin-bottom: 8px; overflow-x: hidden; & > div { will-change: transform, opacity; position: absolute; width: 100%; height: 100%; } ` const StyledImage = styled(animated.div)<{src:string}>` width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; background: ${props=> `url('${props.src}')`} no-repeat center; background-size: contain; ` const PageComponent = (props: any)=>{ const {src} = props return } function BookComponent(props: any) { const {src, currIndex, setBookContextState, flagToReverse} = props const [prevDisable, setPrevDisable] = useState(true) const [nextDisable, setNextDisable] = useState(false) const changePage = useCallback((indexToGo, goToPrevious)=>{ const newCurrIndex = currIndex + indexToGo setBookContextState({ currIndex: newCurrIndex, flagToReverse: goToPrevious }) }, [currIndex]) useEffect(() => { setNextDisable(currIndex >= src.length - 1) setPrevDisable(currIndex <= 0) }, [currIndex, src]) return ( { currIndex=> style=>{ return( {React.createElement(()=>)} ) } } changePage(-1, true)} nextDisable={nextDisable} onNextClick={()=>changePage(1, false)} {...props} /> ) } export default BookComponent