Skip to content
This repository has been archived by the owner on May 23, 2018. It is now read-only.

Commit

Permalink
fix: syntax and bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
troch committed Jul 7, 2015
1 parent 51700e0 commit 7fd80e3
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 40 deletions.
14 changes: 7 additions & 7 deletions dist/amd/link-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ define(['exports', 'module', 'react'], function (exports, module, _react) {
routeName: _React['default'].PropTypes.string.isRequired,
routeParams: _React['default'].PropTypes.object,
routeOptions: _React['default'].PropTypes.object,
activeClass: _React['default'].PropTypes.string,
activeClassName: _React['default'].PropTypes.string,
onClick: _React['default'].PropTypes.func
},

getDefaultProps: function getDefaultProps() {
return {
className: '',
activeClass: 'active',
activeClassName: 'active',
routeParams: {},
routeOptions: {},
onClick: this.clickHandler
Expand All @@ -32,7 +32,7 @@ define(['exports', 'module', 'react'], function (exports, module, _react) {
// Not an anti-pattern
// https://facebook.github.io/react/tips/props-in-getInitialState-as-anti-pattern.html
return {
active: router.isActive(this.props.routeName, this.prop.routeParams)
active: router.isActive(this.props.routeName, this.props.routeParams)
};
},

Expand All @@ -50,7 +50,7 @@ define(['exports', 'module', 'react'], function (exports, module, _react) {
// Should it be an option to observe state in Links?
// Should we add a GroupLink component for menus?
routeChangeHandler: function routeChangeHandler(toState, fromState) {
this.setState({ active: router.isActive(this.props.routeName, this.prop.routeParams) });
this.setState({ active: router.isActive(this.props.routeName, this.props.routeParams) });
},

componentDidMount: function componentDidMount() {
Expand All @@ -65,10 +65,10 @@ define(['exports', 'module', 'react'], function (exports, module, _react) {
var props = this.props;
var active = this.state.active;

var href = router.buildPath(this.props.routeName, this.props.routeParams);
var className = props.className.split(' ').concat(active ? [activeClassName] : []).join(' ');
var href = router.buildUrl(props.routeName, props.routeParams);
var className = props.className.split(' ').concat(active ? [props.activeClassName] : []).join(' ');

return _React['default'].CreateElement('a', { href: href, className: className, onClick: onClick });
return _React['default'].createElement('a', { href: href, className: props.className, onClick: props.onClick });
}
});
}
Expand Down
14 changes: 7 additions & 7 deletions dist/browser/router5-react.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ function linkFactory(router) {
routeName: React.PropTypes.string.isRequired,
routeParams: React.PropTypes.object,
routeOptions: React.PropTypes.object,
activeClass: React.PropTypes.string,
activeClassName: React.PropTypes.string,
onClick: React.PropTypes.func
},

getDefaultProps: function getDefaultProps() {
return {
className: '',
activeClass: 'active',
activeClassName: 'active',
routeParams: {},
routeOptions: {},
onClick: this.clickHandler
Expand All @@ -50,7 +50,7 @@ function linkFactory(router) {
// Not an anti-pattern
// https://facebook.github.io/react/tips/props-in-getInitialState-as-anti-pattern.html
return {
active: router.isActive(this.props.routeName, this.prop.routeParams)
active: router.isActive(this.props.routeName, this.props.routeParams)
};
},

Expand All @@ -68,7 +68,7 @@ function linkFactory(router) {
// Should it be an option to observe state in Links?
// Should we add a GroupLink component for menus?
routeChangeHandler: function routeChangeHandler(toState, fromState) {
this.setState({ active: router.isActive(this.props.routeName, this.prop.routeParams) });
this.setState({ active: router.isActive(this.props.routeName, this.props.routeParams) });
},

componentDidMount: function componentDidMount() {
Expand All @@ -83,10 +83,10 @@ function linkFactory(router) {
var props = this.props;
var active = this.state.active;

var href = router.buildPath(this.props.routeName, this.props.routeParams);
var className = props.className.split(' ').concat(active ? [activeClassName] : []).join(' ');
var href = router.buildUrl(props.routeName, props.routeParams);
var className = props.className.split(' ').concat(active ? [props.activeClassName] : []).join(' ');

return React.CreateElement('a', { href: href, className: className, onClick: onClick });
return React.createElement('a', { href: href, className: props.className, onClick: props.onClick });
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion dist/browser/router5-react.min.js

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

14 changes: 7 additions & 7 deletions dist/commonjs/link-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ function linkFactory(router) {
routeName: _react2['default'].PropTypes.string.isRequired,
routeParams: _react2['default'].PropTypes.object,
routeOptions: _react2['default'].PropTypes.object,
activeClass: _react2['default'].PropTypes.string,
activeClassName: _react2['default'].PropTypes.string,
onClick: _react2['default'].PropTypes.func
},

getDefaultProps: function getDefaultProps() {
return {
className: '',
activeClass: 'active',
activeClassName: 'active',
routeParams: {},
routeOptions: {},
onClick: this.clickHandler
Expand All @@ -37,7 +37,7 @@ function linkFactory(router) {
// Not an anti-pattern
// https://facebook.github.io/react/tips/props-in-getInitialState-as-anti-pattern.html
return {
active: router.isActive(this.props.routeName, this.prop.routeParams)
active: router.isActive(this.props.routeName, this.props.routeParams)
};
},

Expand All @@ -55,7 +55,7 @@ function linkFactory(router) {
// Should it be an option to observe state in Links?
// Should we add a GroupLink component for menus?
routeChangeHandler: function routeChangeHandler(toState, fromState) {
this.setState({ active: router.isActive(this.props.routeName, this.prop.routeParams) });
this.setState({ active: router.isActive(this.props.routeName, this.props.routeParams) });
},

componentDidMount: function componentDidMount() {
Expand All @@ -70,10 +70,10 @@ function linkFactory(router) {
var props = this.props;
var active = this.state.active;

var href = router.buildPath(this.props.routeName, this.props.routeParams);
var className = props.className.split(' ').concat(active ? [activeClassName] : []).join(' ');
var href = router.buildUrl(props.routeName, props.routeParams);
var className = props.className.split(' ').concat(active ? [props.activeClassName] : []).join(' ');

return _react2['default'].CreateElement('a', { href: href, className: className, onClick: onClick });
return _react2['default'].createElement('a', { href: href, className: props.className, onClick: props.onClick });
}
});
}
Expand Down
30 changes: 15 additions & 15 deletions modules/link-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ export default linkFactory
function linkFactory(router) {
return React.createClass({
propTypes: {
routeName: React.PropTypes.string.isRequired,
routeParams: React.PropTypes.object,
routeOptions: React.PropTypes.object,
activeClass: React.PropTypes.string,
onClick: React.PropTypes.func
routeName: React.PropTypes.string.isRequired,
routeParams: React.PropTypes.object,
routeOptions: React.PropTypes.object,
activeClassName: React.PropTypes.string,
onClick: React.PropTypes.func
},

getDefaultProps() {
return {
className: '',
activeClass: 'active',
routeParams: {},
routeOptions: {},
onClick: this.clickHandler
className: '',
activeClassName: 'active',
routeParams: {},
routeOptions: {},
onClick: this.clickHandler
};
},

Expand All @@ -27,7 +27,7 @@ function linkFactory(router) {
// Not an anti-pattern
// https://facebook.github.io/react/tips/props-in-getInitialState-as-anti-pattern.html
return {
active: router.isActive(this.props.routeName, this.prop.routeParams)
active: router.isActive(this.props.routeName, this.props.routeParams)
};
},

Expand All @@ -48,7 +48,7 @@ function linkFactory(router) {
// Should it be an option to observe state in Links?
// Should we add a GroupLink component for menus?
routeChangeHandler(toState, fromState) {
this.setState({active: router.isActive(this.props.routeName, this.prop.routeParams)})
this.setState({active: router.isActive(this.props.routeName, this.props.routeParams)})
},

componentDidMount() {
Expand All @@ -63,11 +63,11 @@ function linkFactory(router) {
let props = this.props
let active = this.state.active

let href = router.buildPath(this.props.routeName, this.props.routeParams);
let href = router.buildUrl(props.routeName, props.routeParams);
let className = props.className.split(' ')
.concat(active ? [activeClassName] : []).join(' ')
.concat(active ? [props.activeClassName] : []).join(' ')

return React.CreateElement('a', {href, className, onClick})
return React.createElement('a', {href, className: props.className, onClick: props.onClick})
}
})
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "router5-react",
"version": "0.1.0-alpha.3",
"version": "0.1.0-alpha.4",
"description": "router5 helpers for React",
"main": "dist/commonjs/index.js",
"scripts": {
Expand All @@ -27,12 +27,12 @@
},
"homepage": "http://router5.github.com/router5/router5-react",
"devDependencies": {
"router5": "0.1.0-rc.4",
"router5": "latest",
"async": "^1.3.0",
"babel": "^5.6.14",
"uglify-js2": "^2.1.11"
},
"peerDependencies": {
"router5": "0.1.0-rc.4"
"router5": ">=0.1.0-rc.5"
}
}

0 comments on commit 7fd80e3

Please sign in to comment.