Skip to content

Commit

Permalink
Move onChange before setState
Browse files Browse the repository at this point in the history
  • Loading branch information
jdlehman committed Apr 4, 2015
1 parent 5ff2726 commit 0bbf93b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 309 deletions.
306 changes: 1 addition & 305 deletions dist/switcheroo.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions modules/components/Switcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ export default class Switcher extends Component {
handleRouteChange(e) {
var newRoute = this.getLocation(),
switchElement = this.getSwitch(newRoute);
this.setState({
visibleComponent: switchElement
});

if(typeof this.props.onChange === 'function') {
this.props.onChange(!!switchElement, newRoute);
}

this.setState({
visibleComponent: switchElement
});
}

render() {
Expand Down

0 comments on commit 0bbf93b

Please sign in to comment.