index.js 1.97 KB
Newer Older
1 2 3
import React, { Component } from 'react'
import './study.scss'

zhanghaozhe committed
4
import { NavLink, Route, Switch, Redirect } from "react-router-dom"
zhanghaozhe committed
5 6
import MyCourses from "./myCourses"
import FreeCourses from './freeCourses'
zhanghaozhe committed
7 8
import WithTab from '@/HOCs/WithTab'
import WithFullSize from '@/HOCs/WithFullSize'
zhanghaozhe committed
9
import { compose } from 'redux'
10

baiguangyao committed
11 12 13

class Study extends Component {

zhanghaozhe committed
14
    state = {
zhanghaozhe committed
15
        position: {
zhanghaozhe committed
16

zhanghaozhe committed
17
        }
zhanghaozhe committed
18 19 20 21 22 23 24 25
    }

    list;

    storeScrollPosition(tab){

    }

baiguangyao committed
26
    render() {
27
        const {match} = this.props;
baiguangyao committed
28
        return (
29
            <section id='study'>
zhanghaozhe committed
30 31
                <div className='tab'>
                    <div>
zhanghaozhe committed
32 33 34 35
                        <NavLink to={`${match.url}/my-course`}
                                 replace
                                 activeClassName='active'
                        >我的课程</NavLink>
zhanghaozhe committed
36 37
                    </div>
                    <div>
zhanghaozhe committed
38 39 40 41
                        <NavLink to={`${match.url}/free-course`}
                                 replace
                                 activeClassName='active'
                        >免费课程</NavLink>
zhanghaozhe committed
42 43
                    </div>
                </div>
zhanghaozhe committed
44
                <div className="study-container" ref={el => this.list = el}>
zhanghaozhe committed
45
                    <Switch>
zhanghaozhe committed
46
                        <Redirect exact from='/study' to='study/my-course'/>
zhanghaozhe committed
47 48 49
                        <Route path={`${this.props.match.path}/my-course`} component={MyCourses}/>
                        <Route path={`${this.props.match.path}/free-course`} component={FreeCourses}/>
                        {/*<Route path={`${this.props.match.path}/my-course`} render={props => {
zhanghaozhe committed
50
                            <MyCourses storeScrollPosition={this.storeScrollPosition}/>
zhanghaozhe committed
51
                        }}/>*/}
zhanghaozhe committed
52 53 54
                        <Route path={`${this.props.match.path}/free-course`} component={FreeCourses}/>
                    </Switch>
                </div>
55
            </section>
baiguangyao committed
56 57 58 59 60
        )
    }

}

zhanghaozhe committed
61 62 63 64
export default compose(
    WithFullSize,
    WithTab
)(Study)