Giter Club home page Giter Club logo

react-works's Introduction

react-works

Monorepo for React components

Gitter CircleCI Dependencies Dev Dependencies

Packages

package npm
packages/bulkhead react-bulkhead
packages/element-resize react-element-resize
packages/swap react-swap
packages/interval react-interval
packages/page-click react-page-click
packages/normalized-select react-normalized-select
packages/text-filter react-text-filter

Development and testing

Install

Currently is being developed and tested with the latest Node 8 on OSX.

git clone [email protected]:nkbt/react-works.git
cd react-works
yarn install

Run tests for all packages

# to run eslint for all packages
yarn lerna run lint

# to run tests for all packages
yarn lerna run test

# to run end-to-end tests for all packages
yarn lerna run e2e

Run package example

To run example covering all package features, use yarn start, which will compile example/index.js

cd packages/package-name
yarn start

# then
open http://localhost:8080

Test one package only

cd packages/package-name

# to run lint
yarn lint

# to run tests
yarn test

License

MIT

react-works's People

Contributors

aeharding avatar greenkeeper[bot] avatar jedwards1211 avatar nkbt 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

Watchers

 avatar  avatar  avatar

react-works's Issues

interval has bug!!!

stop only stop the previous callback !!!
then the next callback wiil go agin!

start 1
stop 1
start 2
stop 2

it will nerver stop!

Changing timeout on the fly is not performant.

It seems like if you try to change the timeout on the fly, It causes a significant CPU spike on less powerful CPUs. I was wondering if this can be mitigated or if you had any specific directions or insights on this. Thanks again for the great work on the library. :)

timer isn't reset when timeout changes

if the timeout is set to 60000 and I render the component a moment later with a timeout of 1000, the callback still doesn't get called until the original 60000 ms is up. Looking at the code it only resets the timer if enabled changes. I'm not sure if this is desirable behavior for any use cases, but it's not for mine, so it would be nice to at least have an option to reset when the timeout changes.

Documentation issue

The documentation indicates the import is:

import ReactInterval from 'react-interval';

The code and testing indicates it should be:

import {ReactInterval} from 'react-interval';

React 16 forward compatibility

  • Update all libs to use ES6 classes
  • Use prop-types library instead of deprecated React.PropTypes
  • Switch to React.PureComponent
  • Drop support for React < 15.3

react-interval: enabled ignored when switched with callback

Hi,

I used the component for a very simple task: count x seconds before stopping the interval.
Surprisingly, the interval never stopped.

Here a sample code

import ReactInterval from 'react-interval';

class Demo extends Component {
  constructor(props) {
    super(props);
    this.state = { remaining: 5 };
    this.onTick = this.onTick.bind(this);
  }

  onTick() {
    const { remaining } = this.state;
    this.setState({ remaining: remaining - 1 });
  }

  render() {
    const { remaining } = this.state;
    return (
      <div>
        <ReactInterval
          enabled={remaining > 0}
          callback={this.onTick}
        />
        <span>{remaining}</span>
      </div>
    );
  }
}

export default Demo;

I found out that stop() was correctly called when enabled switched from true to false, but start() was then immediately called as well.

The issue is kind of related to the life-cycle of the component. For instance, if I use a setTimeout to delay the state change a bit, everything works. But if the enabled prop is switched to false "during" the callback, start() will be called anyway and the interval will not stop.

The culprit is probably this bit:

  callback = () => {
    if (this.timer) {
      this.props.callback();
      this.start();
    }
  };

It should be easily fixed by checking the enabled prop before calling start().

Interval v2.0.0 not available via npm

$ npm install [email protected] --save

npm ERR! Linux 4.4.0-75-generic
npm ERR! argv "/home/chrisp/.nvm/versions/node/v7.5.0/bin/node" "/home/chrisp/.nvm/versions/node/v7.5.0/bin/npm" "install" "[email protected]" "--save"
npm ERR! node v7.5.0
npm ERR! npm  v4.1.2
npm ERR! code ETARGET

npm ERR! notarget No compatible version found: [email protected]
npm ERR! notarget Valid install targets:
npm ERR! notarget 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.0.6, 1.0.8, 1.2.0, 1.2.1, 1.3.0, 1.3.1, 1.3.2, 1.3.3
npm ERR! notarget 
npm ERR! notarget This is most likely not a problem with npm itself.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

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.