molnarmark / preact-flatpickr

📅 Preact wrapper for the Flatpickr library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Initial props are ignored

rosenbjerg opened this issue · comments

When using:

<Flatpickr
	config={{
		weekNumbers: true,
		mode: "range",
		minDate: new Date(),
		defaultDate: state.openRegStart
	}}
	theme="material_blue"
	onChange={() => console.log('You just changed the date.')}>
</Flatpickr>

in a somewhat convoluted render, the config is not used.
I tracked this down to this in the constructor:

this.state = {
	config: {},
	instance: null,
};

Where the config is just an empty object and rely on receiving them later.
My suggested fix is to change the config line to config: props.config && {...props.config} || {},
or just config: props.config || {},.

I have created a pull request with the former of the two