blob: aab22172d7e27f35ffafab5f0c98baecea543365 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
import React, { Component } from 'react'
// import { NavLink } from 'react-router-dom'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { choice } from '../util'
import { history } from '../store'
import * as actions from '../actions'
class PaperRandom extends Component {
componentDidUpdate() {
const { citations } = this.props.api.unknownCitations
if (!citations) return
const citation = choice(citations)
console.log(citation)
if (citation.id) {
history.push('/paper/' + this.props.match.params.key + '/address/' + citation.id)
}
}
render() {
return (
<div>Sending you to a random citation...</div>
)
}
}
const mapStateToProps = state => ({
api: state.api
})
const mapDispatchToProps = dispatch => ({
actions: bindActionCreators({ ...actions }, dispatch),
})
export default connect(mapStateToProps, mapDispatchToProps)(PaperRandom)
|