Coder Social home page Coder Social logo

react-progress-2's Introduction

YouTube style progress bar for ReactJS

Demo

Installation

NPM

npm install react-progress-2

JSPM

jspm install npm:react-progress-2

Usage

Include react-progress-2/main.css to your project. With SystemJS CSS plugin you simply need to write this line:

import "react-progress-2/main.css!"

Include react-progress-2 and put it somewhere in the top-component, for example:

import React from "react";
import Progress from "react-progress-2";

var Layout = React.createClass({
    render: function() {
        return (
            <div className="layout">
                <Progress.Component/>
                {/* other components go here*/}
            </div>
        );
    }
});

Now, whenever you need to show an indicator, just call Progress#show, for example:

loadFeed: function() {
    Progress.show();
    // do your ajax thing.
},

onLoadFeedCallback: function() {
    Progress.hide();
    // render feed.
}

Please note, that show and hide calls are stacked, so after n-consecutive show calls, you need to do n hide calls to hide an indicator or you can use Progress.hideAll().

Styling

Option #1

.loader-60devs .loader-60devs-progress {
    background: #ff6f00;
}

Option #2

  <Progress.Component
    style={{background: 'orange'}}
    thumbStyle={{background: 'green'}} />

Examples

Examples

Contribution

Do the following steps if you have the willing to fix a bug or just add some features to react-progress-2

cd dev
npm install
jspm install
gulp watch
# change the world!

Authors and Contributors

Created in 2015 by Ruslan Prytula (@milworm).

react-progress-2's People

Contributors

milworm avatar seidtgeist avatar tomitakussaari 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  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  avatar  avatar  avatar

react-progress-2's Issues

How to use it on Action using redux?

in my transactionAction.js

import React from 'react';
import Progress from "react-progress-2";

export let getTransactions = () => {
   return dispatch => {
     Progress.show();
     ...
  }
}

I got an error:

Cannot read property '__reactInternalInstance$seae8adebsh' of null
 at Object.getClosestInstanceFromNode (eval at <anonymous> (app.js:1447), <anonymous>:113:11)
    at findParent (eval at <anonymous> (app.js:2011), <anonymous>:38:32)
    at handleTopLevelImpl (eval at <anonymous> (app.js:2011), <anonymous>:67:28)
    at ReactDefaultBatchingStrategyTransaction.perform (eval at <anonymous> (app.js:1579)<anonymous>:140:20)
    at Object.batchedUpdates (eval at <anonymous> (app.js:2005), <anonymous>:62:26)
    at Object.batchedUpdates (eval at <anonymous> (app.js:1561), <anonymous>:97:27)
    at dispatchEvent (eval at <anonymous> (app.js:2011), <anonymous>:147:20)

Uncaught TypeError: Cannot read property 'show' of undefined

Hi I am using Progress Component in multiple component on load. when i load one component is working fine. and the next component load is load, progress coponent work fine for this component, then load data for first component, it showing error "Uncaught TypeError: Cannot read property 'show' of undefined".

please give solution

Getting `show of undefined` error when using in componentWillMount()

I want to use this as an indicator async loading indicator to indicate async route transitions. I have tried this below but it doesn't work because the component is not yet defined:

      componentWillMount() {
        if (!shouldNotShowProgressBar) {
          console.log('loading', api);
          Progress.show();
        }
      }

      componentDidMount() {
        if (!shouldNotShowProgressBar) {
          console.log('loaded', api);
          Progress.hide();
        }
      }

Do you have a working example of this?

Uncaught ReferenceError: Progress is not defined

Hi @milworm ,

I am trying to use your react-progress-2 to in my project. But, I got Progress is not defined error message. I don't know what I did missing. need your help...

Thank you,

Here is my code:

my header area: 1. header.js
import React,{Component} from 'react';
import { Link, IndexLink } from 'react-router';
import Progress from "react-progress-2";
export default class Header extends Component {
constructor(){
super();
}
render(){
return(




<Progress.Component/>
);
}

}

my signin page:
import React, { Component, PropTypes } from 'react';
import { reduxForm } from 'redux-form';
import * as api from '../api/authRepository';
export const fields = [ 'userName', 'password' ]

class Signin extends Component {
handleFormSubmit({ userName, password }) {
Progress.show(); // got error on this area
this.props.signinUser({ userName, password });
}

Configurable overlay.

Will be cool if we could add an ability to show loader with or without transparent blocking overlay.

'window is not defined' when rendering on server

Using react-progress-2 with https://github.com/erikras/react-redux-universal-hot-example results in error below with v4.2.0

[1] [piping] error given was: ReferenceError: window is not defined
[1]     at [object Object].componentWillMount (/Users/austinmao/Sites/aditive-frontend/node_modules/react-progress-2/lib/main.js:73:9)
[1]     at [object Object].ReactCompositeComponentMixin.mountComponent (/Users/austinmao/Sites/aditive-frontend/node_modules/react/lib/ReactCompositeComponent.js:210:12)
[1]     at [object Object].wrapper [as mountComponent] (/Users/austinmao/Sites/aditive-frontend/node_modules/react/lib/ReactPerf.js:66:21)
[1]     at Object.ReactReconciler.mountComponent (/Users/austinmao/Sites/aditive-frontend/node_modules/react/lib/ReactReconciler.js:37:35)
[1]     at ReactDOMComponent.ReactMultiChild.Mixin.mountChildren (/Users/austinmao/Sites/aditive-frontend/node_modules/react/lib/ReactMultiChild.js:241:44)
[1]     at ReactDOMComponent.Mixin._createContentMarkup (/Users/austinmao/Sites/aditive-frontend/node_modules/react/lib/ReactDOMComponent.js:591:32)
[1]     at ReactDOMComponent.Mixin.mountComponent (/Users/austinmao/Sites/aditive-frontend/node_modules/react/lib/ReactDOMComponent.js:479:29)
[1]     at Object.ReactReconciler.mountComponent (/Users/austinmao/Sites/aditive-frontend/node_modules/react/lib/ReactReconciler.js:37:35)
[1]     at ReactDOMComponent.ReactMultiChild.Mixin.mountChildren (/Users/austinmao/Sites/aditive-frontend/node_modules/react/lib/ReactMultiChild.js:241:44)
[1]     at ReactDOMComponent.Mixin._createContentMarkup (/Users/austinmao/Sites/aditive-frontend/node_modules/react/lib/ReactDOMComponent.js:591:32)

Maybe need to put window ref in componentDidMount?

Issue with react-router

Hi!

When I refresh the browser not on index page (for example /users) - I got an error

Uncaught (in promise) TypeError: Cannot read property 'querySelector' of undefined at Constructor.show (main.js:49)
If I start from main page ('/') - all is ok

I use react-router, probably it is the reason of this issue.
Is there some way to fix it?
I've tried to use <Progress.Component/> in parent component.
Also I've tried to place it over Router

<div>
  <Progress.Component/>
   <Router>
      ....
   </Router>
</div>

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.