react-tailwindcss-datepicker icon indicating copy to clipboard operation
react-tailwindcss-datepicker copied to clipboard

Allow setting initial state values from props in addition to useEffect (SSR)

Open bradbyte opened this issue 2 years ago • 0 comments

Thanks for the great library! I'm not sure if this has been requested before, so forgive me if this is a dupe.

I am using this package inside a Remix app, which renders the page on the server. I've noticed that I get a flash of the date picker when it has a value already set.

Essentially useEffect hooks only are fired on the browser after the app mounts. So when this is used to be the only way to update the internal states, you can't have the picker initialized with the correct date(s) from the server.

I think it's a simple (hopefully) as not defaulting the values to null when the come in from props. The useEffect is still correct for changes, since the app has to be mounted in order to interact with it.

I'd be happy to take a crack at this and open a PR if this is approved.

Thanks! -Brad

bradbyte avatar Jul 19 '23 20:07 bradbyte