-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Labels
Description
It seems that prop changes to Container components don't trigger a redraw while adding and removing components does trigger a redraw.
See below a minimal test case:
Clicking the button shows the third rectangle but doesn't change the size of the first one.
import React, { useEffect, useState, useRef, forwardRef, Fragment } from "react"
import { PaperContainer, Layer, Group, Rectangle, Circle, Line, PointText, Arc, Path, renderWithPaperScope } from '@psychobolt/react-paperjs'
export default function TestCanvas() {
const [size, setSize] = useState({ width: '100%', height: '100%' })
const [step, setStep] = useState('a')
const container = useRef()
const onClick = () => {
setStep('b')
}
return (
<Fragment>
<button onClick={onClick}>Test Button</button>
<PaperContainer
ref={container}
canvasProps={{ resize: 'true', style: Object.assign({ backgroundColor: '#F9FAFB' }, size) }}
>
<Rectangle
position={[100, 100]}
size={step === 'b' ? [300, 100] : [100, 100]}
fillColor="white"
radius={20}
strokeWidth={2}
strokeColor="#C4B5FD"
/>
<Group>
<Rectangle
position={[200, 200]}
size={[100, 100]}
fillColor="white"
radius={20}
strokeWidth={2}
strokeColor="#C4B5FD"
/>
{step === 'b' && (
<Rectangle
position={[300, 300]}
size={[100, 100]}
fillColor="white"
radius={20}
strokeWidth={2}
strokeColor="#C4B5FD"
/>
)}
</Group>
</PaperContainer>
</Fragment>
)
}Reactions are currently unavailable