index.js 1.45 KB
Newer Older
zhanghaozhe committed
1 2
import React, { Component } from "react"
import "./study.scss"
3

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

class Study extends Component {
zhanghaozhe committed
12 13 14
  state = {
    position: {},
  }
baiguangyao committed
15

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

zhanghaozhe committed
58
export default compose(WithFullSize, WithTab)(Study)