sojinantony01 / react-cron-generator

Simple react component to generate cron expressions
MIT License
86 stars 63 forks source link

Error when setting state with less header options than default #38

Closed Nathan-Limbik closed 2 years ago

Nathan-Limbik commented 2 years ago

Hi, when using less than the default number of headers, an error occurs when setting an initial Cron value:

Error Value does not match any available headers.

import React from "react";
import Cron from "react-cron-generator";
import "react-cron-generator/dist/cron-builder.css";
import { HEADER } from "react-cron-generator";

export default function App() {
  const [val, setVal] = React.useState("0 0 00 ? * TUE,THU,SAT *");
  const options = { headers: [HEADER.DAILY, HEADER.WEEKLY, HEADER.MONTHLY] };

  return (
    <div>
      <Cron
        onChange={setVal}
        value={val}
        showResultText={true}
        showResultCron={true}
        options={options}
      />
    </div>
  );
}
SojinAntony commented 2 years ago

Thanks @Nathan-Limbik I have found the issue I will try to fix the issue today itself

sojinantony01 commented 2 years ago

The issue is fixed in the latest cron generator version Version: 1.3.6