Apollo1840/StudyTimeBoard

Frontend Upgrade: React fundamental implementation for homepage

Closed this issue · 2 comments

Use React to start building new front-end

mini-spec:

  • A homepage that should look like the current one but build with react
  • Access the new homepage with web api i.g. /modern-beta

Try something like this, it could transplant the frontend to react instantly (tested, it is working, at least for GET page).

import parse from 'html-react-parser';


class App extends React.Component {

  state = {
    page: null,
  }

  componentDidMount() {
      fetch("/home")
      .then(response => response.text()
          .then(data => this.setState({page: parse(data)})))
    }

  render(){return this.state.page;}
}

export default App;

Then we could change the response from flask to json, and get rid of 'parse'. Use react components to re-build the page instead.

A homepage that should look like the current one but build with react (done)
Access the new homepage with web api i.g. /modern-beta