How can I add default value for date picker standalone?
biscet opened this issue · 2 comments
biscet commented
import { Component, createSignal } from 'solid-js';
import DatePicker, { PickerValue } from '@rnwonder/solid-date-picker';
import DatePickerStandAlone from "@rnwonder/solid-date-picker/datePickerStandAlone";
import styles from './App.module.css';
const App: Component = () => {
const [date, setDate] = createSignal<PickerValue>({
value: {
selected: "2021-01-31T23:00:00.000Z"
},
label: ''
});
return (
<div class={styles.App}>
<DatePicker value={date} setValue={setDate} type="single" />
<DatePickerStandAlone type="single" />
</div>
);
};
export default App;
rnwonder commented
<DatePickerStandAlone type="single" value={date().value} />
It uses the value only on this signal. The label is for the input which it lacks as opposed to Datepicker which has the input
const [date, setDate] = createSignal<PickerValue>({
value: {
selected: "2021-01-31T23:00:00.000Z"
},
label: ''
});
You could do something like this instead
import { IDatePickerInputValueTypes } from "@rnwonder/solid-date-picker";
const [date, setDate] = createSignal<IDatePickerInputValueTypes>();
<DatePickerStandAlone type="single" value={date()} />
I will simplify this type name in future versions IDatePickerInputValueTypes
but this is what its called currently
Also it doesnt have a setValue you have to handle that yourself in
onChange={(data) => {
if (data.type === "single") {
console.log(data.selectedDate)
// set date value
}
}}