Giter VIP home page Giter VIP logo

react-cron-generator's Introduction

react-cron-generator

Simple react component to generate cron expression

Getting Started

Package helps to build linux scheduler cron expression.

npm version Downloads license E2E tests passing.

data = '* * * * * * *'
npm install react-cron-generator

demo

Live demo

alt text

alt text

import React, { Component } from 'react'
import Cron from 'react-cron-generator'
import 'react-cron-generator/dist/cron-builder.css'


class App extends Component {

  constructor(props) {
      super(props);
      this.state = {
       
      };
  }

  render() {
    return (<div>
      <Cron
        onChange={(e)=> {this.setState({value:e});}}
        value={this.state.value}
        showResultText={true}
        showResultCron={true}
        />
                            
    </div>)
  }
}

export default App;

props

Prop Description Default Mandatory
value cron expression No
onChange have 2 arguments, 1st is cron value and 2nd is cron result text from cronstrue Yes
showResultText show in readable text format false No
showResultCron show cron expression false No
translateFn translate function callback method No
locale locale for cronstrue en No
options Options for Cron component, *Must pass a valid cron value for available headers All available headers No
disabled Disable cron selector false No

translateFn

Expects a method. Use this prop for localization support. react-cron-generator will call this method for every key. List of keys are available here

locale option should be set for correct ResultText translation. Please visit cronstrue for supported locales.

Options

options.headers

import { HEADER } from 'react-cron-generator';

const options = {
  headers: [HEADER.MONTHLY, HEADER.WEEKLY, HEADER.MINUTES, HEADER.HOURLY, HEADER.DAILY, HEADER.CUSTOM]
};

Release notes 2.x.x

  1. Build Procedure updated
  2. Updated to latest react(18)
  3. Migrated to hooks and typescript

Sojin Antony

"Buy Me A Coffee"

Acknowledgments

cronstrue

Viswanath Lekshmanan

react-cron-generator's People

Contributors

bibinantony1998 avatar jpranays avatar jtl3d avatar kishankpatel avatar mawarudoll avatar sojinantony avatar sojinantony01 avatar viswanathlekshmanan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

react-cron-generator's Issues

When setting the cron expression '* * * * * * *' as the initial value and opening the generator, it is not recognized.

Intended behavior:
When '* * * * * * ' is entered, the custom header should be selected, and ' * * * * * *' should be filled in.

However, an error message saying "An error occured when generating the expression description. Check the cron expression syntax." appears.

or

When the time tab is selected, it automatically converts to '0 0 00 1/1 * ? *'.

  const [result, setResult] = useState('* * * * * * *');
  
  <Cron
      onChange={(e) => {
          setResult(e);
      }}
      value={result}
      showResultText
      showResultCron={false}
  />

Selecting Daily tab and radio button behave weirdly

  • babelify js is not behaving properly (dist).
  • I tried installing package and use inside my react app.
  • Could be because of the depicated life cycles and index as a key.

How to produce

  • Click on Month tab
  • Then try clicking on Daily tab. It will take you to Hour tab
  • Second one is click on Daily tab and then switch between radion button.
  • Selecting first radio button will again redirect you to Hour tab

React version: "react": "^16.13.1"
package version: "react-cron-generator": "^1.2.5"

Wrong tab index on tab change

Hi,

I pass to options prop what header is not including MINITES, so it is defaultTabs index 0. My header options index 0 is Hourly. defaultValue function return metada index and metadata index 0 is always MINUTES but my header options index 0 is Hourly.
When i change tab to HOURLY, i receive MINUTES data because HOURLY index is 0 in my array but metadata index 0 is MINUTES.

Cron formatting

What format does this use? It doesn't seem to be valid cron that I am aware of. For instance if I did a cron task for every 6 hours it generates this string: 0 0 0/6 1/1 * ? * when the cron I am familiar with would look like 0 */6 * * *

Module not found: Can't resolve '@babel/runtime/helpers/esm/extends'

It shows following error on compile

Module not found: Can't resolve '@babel/runtime/helpers/esm/extends'

the project is created with create-react-app and is not ejected.
It uses babel 7.9.0.
Looks like react-cron-generator is build with older version of babel which causes this problem

Console Warnings for componentWillMount and componentWillReceiveProps

The console logs two warnings for the usages of "componentWillMount" and "componentWillReceiveProps"

Warning: componentWillMount has been renamed, and is not recommended for use. See https://fb.me/react-unsafe-component-lifecycles for details.

  • Move code with side effects to componentDidMount, and set initial state in the constructor.
  • Rename componentWillMount to UNSAFE_componentWillMount to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run npx react-codemod rename-unsafe-lifecycles in your project source folder.

Please update the following components: Cron, HourlyCron

Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-unsafe-component-lifecycles for details.

  • Move data fetching code or side effects to componentDidUpdate.
  • If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state
  • Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run npx react-codemod rename-unsafe-lifecycles in your project source folder.

Please update the following components: Cron

TypeScript with complete definitions

Hi :) Will this be updated to support typescript also? Getting this message

Could not find a declaration file for module 'react-cron-generator'. 'xxx/node_modules/react-cron-generator/dist/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/react-cron-generator` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-cron-generator';

Had to solve it temporary by adding "noImplicitAny": false in my tsconfig.json file

Support for AWS

Hi,

I'm playing with a backend/frontend tool (full stack) that involves cron expressions and AWS.

For the frontend part of the app I find this package a must have.

Right now I can work with unix cron expressions, but, is there any option to have support for AWS EventBridge cron expressions? (are similar to unix expressions, but not compatible).

For the backend part I found a solution here time ago (in case you can find it useful for more context)
vcoder4c/cron-validator#10

Many thanks.

Coverage issues

Getting:

node_modules\react-cron-generator\dist\monthly.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
SyntaxError: Unexpected identifier

I think you should rename the .babelrc file to babel.config.js which will export .babelrc object.

Cron expression in unix based format

Cron expression output is basically a quartz style format having 7 no of fields. Is there any way to get it in a UNIX based style ( 5 or 6 no of field)

Showing different tab content after passing headers manually as options

First of all, I would like to thank you for the awesome plugin.

I am facing an issue with the plugin. Here are the details of the issue,

I tried to pass headers options with Monthly, Weekly, and Daily options, but it is always showing tab contents of the Hourly tab. It is working fine with options only if I pass options sequentially [HEADER.MINUTES, HEADER.HOURLY, HEADER.DAILY]

Here is my code sample,

const cronHeaderOptions = {
headers: [HEADER.MONTHLY, HEADER.WEEKLY, HEADER.DAILY]
};

//-----

<Cron
onChange={ (value)=> { setFieldValue('trigger_period', value) } }
value={values.trigger_period}
name="trigger_period"
showResultText={true}
options={cronHeaderOptions}
/>

image

Please let me know if there is any configuration I am missing.
Thank you.

Support for 6 character cron strings

From what I can tell, only 7 character cron strings are supported as of this time. If I set the value to a 6 character cron string, the tool seems to default to the picture below
image

It also changes the cron string to an "every one minute" 7-character representation (0 0 00 1 1/1 ? *).

An example of a 6 character cron string that I am using: 0 15 1 ? * *

Weekday, day and month ranges

Dear team
Would like to check with you if there is any plan to interpret ranges using '-' in react-cron-generator
E.g. when selecting Monday,Tuesday,Wednesday,Thursday then it ideally would translate into MON-THU rather than MON,TUE,WED,THU - please let me know if this is something in plans.
And similarly for other continuous selections.
Thank you and regards, Mike.

Component does not react to changes in value outside of the Component

If I change the value of the cron from outside the component, the component does not update its value. This is because it reads the value from props into state from within ComponentWillMount, and that function is only called once on the first render.

It should update the state with the new value every time it changes externally.

It could either implement static getDerivedStateFromProps(props, state) to update the state when the props value changes or just use the value directly from the props and skip the state. Looking at the code, you don't really need the value stored in the state. You could add a function to compute the value from the props and call it where you need it instead of storing it in the state.

An example use case here, is that I have a list of schedules with edit buttons, and one CronGenerator component. When I click on a schedule to edit it, I need to update the CronGenerator with this schedule's cron. This does not work because the CronGenerator only checks my value prop in ComponentWillMount.

Css does not working

Hi, I imported the css file from the package, but the component still shows no styles. Here is a live example. Thank you
codesandbox

Incompatibility with the react 16.x version

./node_modules/react-cron-generator/build/index.js
Module not found: Can't resolve 'react/jsx-runtime' in '..\node_modules\react-cron-generator\build'
current react version is : 16.13.1
how cant I fix this bug ?

[feature request] localization support

Great tool, thanks for making it.
Unfortunately, it lacks any means to localize the component, as all the text is hard-coded.
So this is a feature request: to add a way to customize the text in the UI for non-english projects to be able to use it as well.

SyntaxError: Unexpected token

In the latest version I'm getting this error.

SyntaxError:/node_modules/react-cron-generator/build/index.js: Unexpected token (7490:8)
  7488 |                 throw new Error('translateFn expects a string translation');
  7489 |             }
> 7490 |         }
       |         ^
  7491 |         return translatedText;
  7492 |     };
  7493 |     return (jsxRuntime.jsxs("div", Object.assign({ className: 'cron_builder' }, { children: [jsxRuntime.jsx("ul", Object.assign({ className: "nav nav-tabs" }, { children: getHeaders() })), jsxRuntime.jsx("div", Object.assign({ className: "cron_builder_bordering" }, { children: state.selectedTab ? getComponent(state.selectedTab) : "Select a header" })), props.showResultText && jsxRuntime.jsx("div", Object.assign({ className: "cron-builder-bg" }, { children: getVal() })), props.showResultCron && jsxRuntime.jsx("div", Object.assign({ className: "cron-builder-bg" }, { children: state.value.toString().replace(/,/g, ' ').replace(/!/g, ',') }))] })));
WARNING in ./node_modules/react-cron-generator/build/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'index.js.map': SyntaxError: Unexpected token C in JSON at position 504225

ERROR in ./node_modules/react-cron-generator/build/index.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError:/node_modules/react-cron-generator/build/index.js: Unexpected token (7490:8)

  7488 |                 throw new Error('translateFn expects a string translation');
  7489 |             }
> 7490 |         }
       |         ^
  7491 |         return translatedText;
  7492 |     };
  7493 |     return (jsxRuntime.jsxs("div", Object.assign({ className: 'cron_builder' }, { children: [jsxRuntime.jsx("ul", Object.assign({ className: "nav nav-tabs" }, { children: getHeaders() })), jsxRuntime.jsx("div", Object.assign({ className: "cron_builder_bordering" }, { children: state.selectedTab ? getComponent(state.selectedTab) : "Select a header" })), props.showResultText && jsxRuntime.jsx("div", Object.assign({ className: "cron-builder-bg" }, { children: getVal() })), props.showResultCron && jsxRuntime.jsx("div", Object.assign({ className: "cron-builder-bg" }, { children: state.value.toString().replace(/,/g, ' ').replace(/!/g, ',') }))] })));
    at instantiate (node_modules/@babel/parser/lib/index.js:72:32)
    at constructor (node_modules/@babel/parser/lib/index.js:358:12)
    at Parser.raise (node_modules/@babel/parser/lib/index.js:3336:19)
    at Parser.unexpected (node_modules/@babel/parser/lib/index.js:3374:16)
    at Parser.parseExprAtom (node_modules/@babel/parser/lib/index.js:13120:22)
    at Parser.parseExprSubscripts (node_modules/@babel/parser/lib/index.js:12645:23)
    at Parser.parseUpdate (node_modules/@babel/parser/lib/index.js:12624:21)
    at Parser.parseMaybeUnary (node_modules/@babel/parser/lib/index.js:12595:23)
    at Parser.parseMaybeUnaryOrPrivate (node_modules/@babel/parser/lib/index.js:12389:61)
    at Parser.parseExprOps (node_modules/@babel/parser/lib/index.js:12396:23)

Test case failed due to cron

I have to use react-cron-generator to display cron options. When I add them its fails my test cases.

I created react app using create-react-app package.

npx create-react-app cron-test

Then I added eslint and other needed package. after that my package.json is as below.

{
  "name": "cron-test",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "@typescript-eslint/parser": "^4.7.0",
    "cross-env": "^7.0.2",
    "eslint": "^7.13.0",
    "react": "^17.0.1",
    "react-cron-generator": "^1.2.6",
    "react-dom": "^17.0.1",
    "react-scripts": "4.0.0",
    "run-scripts": "^0.4.0",
    "typescript": "^4.0.5",
    "web-vitals": "^0.2.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "run-scripts test:unit test:lint test:build",
    "test:build": "run-scripts build",
    "test:lint": "eslint ./src",
    "test:unit": "cross-env CI=1 react-scripts test --env=jsdom",
    "test:watch": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Then I run my yarn test it works fine.

AAFFVVSS:cron-test myuser$ yarn test
yarn run v1.22.5
$ run-scripts test:unit test:lint test:build

> [email protected] test:unit /Users/myuser/react/cron-test
> cross-env CI=1 react-scripts test --env=jsdom


npm WARN lifecycle The node binary used for scripts is /var/folders/rt/7_nbtrwx0q305tx_z9tk1l9538x_ng/T/yarn--1605020623793-0.8495721275316386/node but npm is using /usr/local/Cellar/node/14.5.0/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
PASS src/App.test.js
  ✓ renders learn react link (36 ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        1.986 s, estimated 2 s
Ran all test suites.


> [email protected] test:lint /Users/myuser/react/cron-test
> eslint ./src


npm WARN lifecycle The node binary used for scripts is /var/folders/rt/7_nbtrwx0q305tx_z9tk1l9538x_ng/T/yarn--1605020623793-0.8495721275316386/node but npm is using /usr/local/Cellar/node/14.5.0/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.


> [email protected] test:build /Users/myuser/react/cron-test
> run-scripts build


> [email protected] build /Users/myuser/react/cron-test
> react-scripts build

Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

  41.2 KB  build/static/js/2.9edf6727.chunk.js
  1.39 KB  build/static/js/3.71dde3ee.chunk.js
  1.17 KB  build/static/js/runtime-main.66726b93.js
  592 B    build/static/js/main.f42a7f12.chunk.js
  546 B    build/static/css/main.ab7136cd.chunk.css

The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.

The build folder is ready to be deployed.
You may serve it with a static server:

  yarn global add serve
  serve -s build

Find out more about deployment here:

  https://cra.link/deployment



npm WARN lifecycle The node binary used for scripts is /var/folders/rt/7_nbtrwx0q305tx_z9tk1l9538x_ng/T/yarn--1605020623793-0.8495721275316386/node but npm is using /usr/local/Cellar/node/14.5.0/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
npm WARN lifecycle The node binary used for scripts is /var/folders/rt/7_nbtrwx0q305tx_z9tk1l9538x_ng/T/yarn--1605020623793-0.8495721275316386/node but npm is using /usr/local/Cellar/node/14.5.0/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
Browserslist: caniuse-lite is outdated. Please run the following command: `npx browserslist --update-db`


✨  Done in 13.14s.

But when I try to include react-cron-generator it start failing, I just added import Cron from 'react-cron-generator'.

$ cat src/App.js
import logo from './logo.svg';
import './App.css';

import Cron from 'react-cron-generator'

function App() {
  return (
    <div className="App">
      <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />
        <p>
          Edit <code>src/App.js</code> and save to reload.
        </p>
        <a
          className="App-link"
          href="https://reactjs.org"
          target="_blank"
          rel="noopener noreferrer"
        >
          Learn React
        </a>
      </header>
    </div>
  );
}

export default App;

If filed on import

AAFFBB:cron-test myuser$ yarn test
yarn run v1.22.5
$ run-scripts test:unit test:lint test:build

> [email protected] test:unit /Users/myuser/react/cron-test
> cross-env CI=1 react-scripts test --env=jsdom


npm WARN lifecycle The node binary used for scripts is /var/folders/rt/7_nbtrwx0q305tx_z9tk1l9538x_ng/T/yarn--1605020858015-0.9897713366854908/node but npm is using /usr/local/Cellar/node/14.5.0/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
FAIL src/App.test.js
  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/en/ecmascript-modules for how to enable it.
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /Users/myuser/react/cron-test/node_modules/react-cron-generator/dist/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import Cron from './cron';
                                                                                             ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      2 | import './App.css';
      3 |
    > 4 | import Cron from 'react-cron-generator'
        | ^
      5 |
      6 | function App() {
      7 |   return (

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1350:14)
      at Object.<anonymous> (src/App.js:4:1)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        2.03 s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test:unit: `cross-env CI=1 react-scripts test --env=jsdom`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test:unit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/myuser/.npm/_logs/2020-11-10T15_07_41_722Z-debug.log

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Seems like issue is at https://github.com/sojinantony01/react-cron-generator/blob/master/src/lib/index.js#L1, but is there any way to ignore it ?

Hourly tab: unable to set 0 hour

Hello!

When we enter in the Hourly tab the hour value is 0 and the result expression is "0 0 0/1 1/1 * ? *".

If we change the hour time e trying go back to 0 is not possible, the input only allow an empty value but the expression value is "0 0/1 1/1 * ? *".

As we can see they are different:
"0 0 0/1 1/1 * ? *"
"0 0/1 1/1 * ? *"

Best Regards, David

Changing Tab also modifies the underlying cron value

Thanks for the nice tool. Here is an issue I found:

For example:
If my initial cron value is "every 5 minute(s)", and
I change tab from "Minutes" to "Hourly" and then back to "Minutes".

The cron value is now "Every 1 minute(s)".

Expected result:
The cron value should not change just because I changed tab

Css does not work on bootstrap 4.6.0 version.

Hello,

I am using bootstrap 4.6.0 version and component css does not work with it? I saw a post that you will upgrade bootstrap version 3 to 4? Is there any progress on that?

Thanks
Erkan

Content security policy error

Hello, while I was using the component (great stuff by the way), everything was fine in dev, and when I built the app for production, I got the following error:

Refused to execute inline script because it violates the following Content Security Policy directive: "default-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-KpHv3zgivMSB4dPnfYfqMt2lBibsYvM36EdoBBAsfbM='), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.

I didn't get to any meaningfull answer so if you can lend me a hand in solving this I would appriciate it, I will post any code you need.

Using only one header as option is throwing error

const options = { headers: [HEADER.MINUTES] };

Screenshot 2020-07-10 at 12 41 15 PM

Note:

  • If state is empty then only it is throwing error.
  • Setting up a default value will avoid this error (const [value, setValue] = useState('0 0/6 * * * ? *');)

Error when setting state with less header options than default

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>
  );
}

Cannot seem to initialize expression value for editing

Firstly, thanks for creating this package, I love it.

I am having trouble initializing the cronExpression value - even when I provide it a value that it previously provided, the Component always displays "An error occured when generating the expression description. Check the cron expression syntax."

Below is a sample of what I am trying to do:

import React, { useState } from 'react';
import Cron from 'react-cron-generator';

export default function TestPage() {
  const [cronExpression, setCronExpression] = useState(null);
  const [cronExpressionText, setCronExpressionText] = useState('');

  return (<>

<button onClick={()=>{
  setCronExpression(null);
 }}>Set Null</button>

<input type="text" value={cronExpressionText} onChange={(e)=>setCronExpressionText(e.target.value)} />

<button onClick={()=>{
  setCronExpression(cronExpressionText);
 }}>Set Value</button>


{cronExpression &&
      <Cron
        onChange={(e)=> {
          console.log(`changed to "${e}"`);
          setCronExpression(e);
        }}
        value={cronExpression}
        showResultText={true}
        showResultCron={true}
        />
        }
    </>
  );
}

Using the above example, if I type into the text field:
0 0 00 1/1 * ? *

and click set value, the Cron component appears but it displays the error, even though this value was a value provided by the Component.

Any idea how I can get this to work?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.