Skip to content

Commit 2e380ce

Browse files
committed
use Connected-React-Router to navigate
1 parent f26dea2 commit 2e380ce

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

browser/components/MarkdownPreview.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import PropTypes from 'prop-types'
22
import React from 'react'
3+
import { connect } from 'react-redux'
34
import Markdown from 'browser/lib/markdown'
45
import _ from 'lodash'
56
import CodeMirror from 'codemirror'
@@ -23,7 +24,7 @@ import i18n from 'browser/lib/i18n'
2324
import fs from 'fs'
2425
import { render } from 'react-dom'
2526
import Carousel from 'react-image-carousel'
26-
import { hashHistory } from 'react-router'
27+
import { push } from 'connected-react-router'
2728
import ConfigManager from '../main/lib/ConfigManager'
2829

2930
const { remote, shell } = require('electron')
@@ -206,7 +207,7 @@ function getSourceLineNumberByElement (element) {
206207
return parent.dataset.line !== undefined ? parseInt(parent.dataset.line) : -1
207208
}
208209

209-
export default class MarkdownPreview extends React.Component {
210+
class MarkdownPreview extends React.Component {
210211
constructor (props) {
211212
super(props)
212213

@@ -1021,6 +1022,7 @@ export default class MarkdownPreview extends React.Component {
10211022
parser.href = e.target.getAttribute('href')
10221023
const { href, hash } = parser
10231024
const linkHash = hash === '' ? rawHref : hash // needed because we're having special link formats that are removed by parser e.g. :line:10
1025+
const { dispatch } = this.props
10241026

10251027
if (!rawHref) return // not checked href because parser will create file://... string for [empty link]()
10261028

@@ -1069,7 +1071,7 @@ export default class MarkdownPreview extends React.Component {
10691071
const regexIsTagLink = /^:tag:#([\w]+)$/
10701072
if (regexIsTagLink.test(rawHref)) {
10711073
const tag = rawHref.match(regexIsTagLink)[1]
1072-
hashHistory.push(`/tags/${encodeURIComponent(tag)}`)
1074+
dispatch(push(`/tags/${encodeURIComponent(tag)}`))
10731075
return
10741076
}
10751077

@@ -1106,3 +1108,5 @@ MarkdownPreview.propTypes = {
11061108
smartArrows: PropTypes.bool,
11071109
breaks: PropTypes.bool
11081110
}
1111+
1112+
export default connect()(MarkdownPreview)

0 commit comments

Comments
 (0)