-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathnext.js
38 lines (33 loc) · 980 Bytes
/
next.js
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
37
38
import React, { useContext } from 'react'
import styled from 'styled-components'
import CharacterContext from './character-context'
// import api from './api'
import NProgress from 'nprogress'
import { useHistory } from 'react-router-dom'
const NextStyled = styled.div`
cursor: pointer;
/* border: 1px solid red; */
background-image: url('./images/arrow.svg');
background-repeat: no-repeat;
background-position: left bottom;
flex: 1;
@media screen and (max-width: 1024px) {
user-select: none;
height: 50px;
background-position: center;
}
`
function Next() {
const context = useContext(CharacterContext)
const history = useHistory()
async function handleClick() {
NProgress.start()
history.push(`${process.env.PUBLIC_URL}/${context.character.id + 1}`)
// context.setCharacter(await api.getCharacter(context.character.id + 1))
NProgress.done()
}
return (
<NextStyled onClick={handleClick} />
)
}
export default Next