react-chrono icon indicating copy to clipboard operation
react-chrono copied to clipboard

Re-render color props on state change

Open maheshwarimrinal opened this issue 3 years ago • 7 comments

Describe the bug Re-render issue when state change

To Reproduce Try changing colors with state change, suppose I toggle light and dark mode in webapp but if other components re render the timeline don't with expected colors

Expected behavior Colors should change with the props passed

Desktop (please complete the following information):

  • OS: every OS
  • Browser every browser

Smartphone (please complete the following information): Every other smartphone

maheshwarimrinal avatar May 23 '21 14:05 maheshwarimrinal

can you update the lib to the latest version 1.12.0 and check if this is still happening?

please reopen if you have queries or issues.

prabhuignoto avatar Sep 14 '21 06:09 prabhuignoto

Yes, the issue is still happening. I'm toggling between dark/light theme and from what I noticed:

  • primary color doesn't update for cardSubtitle however it does update correctly for card title
  • cardBgColor doesn't update correctly
  • cardForeColor doesn't update correctly

You need to reload the page or switch to another route first to get the right theme. I tried both on theme switch and neither works :

  1. render an entire another Chrono component with a new theme object
  2. tweak directly the theme prop

mthanasi avatar Sep 15 '21 09:09 mthanasi

@mthanasi can you post me the link to your repo where this happens.

prabhuignoto avatar Sep 15 '21 09:09 prabhuignoto

@prabhuignoto The repo is private but I recreated the component and the issue in this codesandbox : https://codesandbox.io/s/muddy-wildflower-vlr7m?file=/src/index.js

mthanasi avatar Sep 15 '21 14:09 mthanasi

Do we have a workaround for it?

gutsytechster avatar Dec 12 '21 12:12 gutsytechster

@gutsytechster I managed to get around this. It is a bit messy and you may lose the card border, definitely not an optimal solution. But if you set the cardForeColor and cardBGColor to nonsensical values, then the card will revert to using the parent's color scheme. Then you can assign the color to the parent based on the color mode. https://codesandbox.io/s/condescending-lichterman-lik4wz?file=/src/app.js

sandheepsebastain avatar Mar 04 '22 23:03 sandheepsebastain

You can change key(by hooks) in react component it will render

SiDDhartharG avatar Mar 28 '22 10:03 SiDDhartharG