Skip to content

Commit

Permalink
Release v2.4.1
Browse files Browse the repository at this point in the history
If the Loading Bar is mounted with loading count > 0, it should launch
the progress simulation immediately
  • Loading branch information
mironov committed Nov 5, 2016
1 parent e9dc93c commit 4dedc7c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Release History

## 2.4.1
- If the Loading Bar is mounted with loading count > 0, it should launch the progress simulation immediately

## 2.4.0
- Do not apply styling if CSS class is specified

Expand Down
7 changes: 7 additions & 0 deletions build/loading_bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ var LoadingBar = exports.LoadingBar = function (_React$Component) {
}

_createClass(LoadingBar, [{
key: 'componentWillMount',
value: function componentWillMount() {
if (this.props.loading > 0) {
this.launch();
}
}
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
if (nextProps.loading > this.props.loading) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-redux-loading-bar",
"version": "2.4.0",
"version": "2.4.1",
"description": "Simple Loading Bar for Redux and React",
"main": "build/index.js",
"scripts": {
Expand Down
6 changes: 6 additions & 0 deletions spec/loading_bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ describe('LoadingBar', () => {
expect(spyLaunch).toNotHaveBeenCalled()
expect(spyLaunch.calls.length).toEqual(0)
})

it('launches on component mount if loading count is > 0', () => {
shallow(<LoadingBar loading={1} />)
expect(spyLaunch).toHaveBeenCalled()
expect(spyLaunch.calls.length).toEqual(1)
})
})

describe('#componentWillUnmount', () => {
Expand Down
6 changes: 6 additions & 0 deletions src/loading_bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ export class LoadingBar extends React.Component {
this.boundResetProgress = this.resetProgress.bind(this)
}

componentWillMount() {
if (this.props.loading > 0) {
this.launch()
}
}

componentWillReceiveProps(nextProps) {
if (nextProps.loading > this.props.loading) {
this.launch()
Expand Down

0 comments on commit 4dedc7c

Please sign in to comment.