Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Upgrade to styled-components-4 #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"test:watch": "nwb test-react --server"
},
"dependencies": {
"styled-components": "^3.1.6"
"styled-components": "^4.4.1"
},
"peerDependencies": {
"prop-types": "^15.6.0",
Expand Down
14 changes: 8 additions & 6 deletions src/components/Annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export default compose(
withRelativeMousePos()
)(class Annotation extends Component {
static propTypes = {
innerRef: T.func,
onMouseUp: T.func,
onMouseDown: T.func,
onMouseMove: T.func,
Expand Down Expand Up @@ -89,8 +88,11 @@ export default compose(

static defaultProps = defaultProps

imgRef = React.createRef();
targetRef = React.createRef();

componentDidMount() {
this.setInnerRef(this.imgRef)
if (this.props.allowTouch) {
this.addTargetTouchEventListeners();
}
Expand Down Expand Up @@ -125,10 +127,11 @@ export default compose(
}
}

setInnerRef = (el) => {
setInnerRef = (ref) => {
const el = ref.current
this.container = el
this.props.isMouseHovering.innerRef(el)
this.props.relativeMousePos.innerRef(el)
this.props.innerRef(el)
}

getSelectorByType = (type) => {
Expand Down Expand Up @@ -250,7 +253,6 @@ export default compose(
return (
<Container
style={props.style}
innerRef={isMouseHovering.innerRef}
onMouseLeave={this.onTargetMouseLeave}
onTouchCancel={this.onTargetTouchLeave}
allowTouch={allowTouch}
Expand All @@ -261,7 +263,7 @@ export default compose(
alt={props.alt}
src={props.src}
draggable={false}
innerRef={this.setInnerRef}
ref={this.imgRef}
/>
<Items>
{props.annotations.map(annotation => (
Expand All @@ -282,7 +284,7 @@ export default compose(
}
</Items>
<Target
innerRef={this.targetRef}
ref={this.targetRef}
onClick={this.onClick}
onMouseUp={this.onMouseUp}
onMouseDown={this.onMouseDown}
Expand Down
Loading