• 1399/04/28

simple react validator در typescript :

سلام آقای قربانی وقت شما بخیر

من میخوام از simplereactvalidator در typescript استفاده کنم همش خطا میده لطف میکنید راهنمایی کنید؟

خطایی که میده :

<span data-ansi-line="true"><span>An index signature parameter type cannot be a type alias. Consider writing '[key: string]: { message: string; rule: (val: any, params?: any) => boolean; }' instead</span></span>

کد من:

const validator = useRef(

       new SimpleReactValidator({

           messages: {

               required: "پر کردن این فیلد الزامی است"

           },

           element: (message: string) => <div className="text-danger">{message}</div>

       })

   );

<input

                           type="text"

                           name="mobile"

                           className="form-control"

                           placeholder="موبایل"

                           aria-describedby="mobile-address"

                           value={mobile}

                           onChange={(e) => {

                               setMobile(e.target.value);

                               validator.current.showMessageFor("mobile");

                           }}

                       />

                       {validator.current.message(

                           "mobile",

                           mobile,

                           "required"

                       )}

  • 1399/04/30
  • ساعت 10:01

سلام دوست من

متاسفانه من تایپ اسکریپت کار نمی کنم و نمیتونم راهنماتون باشم در این ضمینه


logo-samandehi