puncoz-official / nepali-datepicker-reactjs

Nepali Datepicker (Bikram Sambat) as a ReactJS component
https://puncoz-official.github.io/nepali-datepicker-reactjs/
Other
28 stars 44 forks source link

'string' is not defined no-undef #45

Closed Laxman980 closed 4 months ago

Laxman980 commented 4 months ago

import { NepaliDatePicker } from "nepali-datepicker-reactjs" import "nepali-datepicker-reactjs/dist/index.css" export default function Creatpost()

{ const [date, setDate] = useState("") } <NepaliDatePicker inputClassName="form-control" className="" value={date} onChange={(value: string) => setDate(value)} options={{ calenderLocale: "ne", valueLocale: "en" }} />

puncoz commented 4 months ago

hi @Laxman980, it seems you are working with javascript. So, please remove all type definitions and it should work. In above code there is type defined in onChange={(value: string) => setDate(value)} it should be onChange={(value) => setDate(value)}

Sample working code for JavaScript:

import React, { useState } from "react"
import { NepaliDatePicker } from "nepali-datepicker-reactjs"
import "nepali-datepicker-reactjs/dist/index.css"

const App = () => {
    const [date, setDate] = useState("")

    return (
        <form>
            <label htmlFor="date">Date</label>
            <NepaliDatePicker inputClassName="form-control"
                              className=""
                              value={date}
                              onChange={(value) => setDate(value)}
                              options={{ calenderLocale: "ne", valueLocale: "en" }} />
        </form>
    )
}

export default App