mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-09 14:45:35 +00:00
more react changes, incomplete
This commit is contained in:
31
src/app/components/Link.jsx
Normal file
31
src/app/components/Link.jsx
Normal file
@@ -0,0 +1,31 @@
|
||||
import React from 'react';
|
||||
import Router from '../Router';
|
||||
import shallowEqual from '../utils/shallowEqual';
|
||||
|
||||
export default class Link extends React.Component {
|
||||
|
||||
shouldComponentUpdate(nextProps) {
|
||||
return !shallowEqual(this.props, nextProps);
|
||||
}
|
||||
|
||||
handler = (event) => {
|
||||
if (event.getModifierState
|
||||
&& ( event.getModifierState('Shift')
|
||||
|| event.getModifierState('Alt')
|
||||
|| event.getModifierState('Control')
|
||||
|| event.getModifierState('Meta')
|
||||
|| event.button > 1)) {
|
||||
return;
|
||||
}
|
||||
event.nativeEvent && event.preventDefault && event.preventDefault();
|
||||
|
||||
if (this.props.href) {
|
||||
Router.go(encodeURI(this.props.href));
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return <a {...this.props} onClick={this.handler}>{this.props.children}</a>
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user