react
package.json
proxy:"http://localhost:3001"
npm -i -s axios //http
import {get} from Axios
get('/api/teacher).then....
npm run build
build folder -- index.html
to take to real word with html, css and js
Because it is a class I can do state****
next to pass to the router ????
in react you can nest routers
<Router>
<Route path='/urls' component={URLSPage}/>
</Router>
URLPage
<div>
<h1> urls </h1>
<Route path = '/urls/:id' ... component is urlpage>
...
hash slash mode...
npm i s react-router-dom
import {HashRouter as Router, Route, Link} from react-router-dom..
wrap in <Router>...
<link
<Route path='/teatcher' component={TeachersPage}/> </Router>
lifecycle components
class Presenter ex.. Component {
constructor(props){
super(props);
this.state = { loading: true };
}
componentDidMount(){
this.fetch(this.props.match.id);
}
fetch(id){
this.setState({loading:true});
getStuff(id).then(({data})=> this.setState({data,state:false}););
componentwillreceivepropost(newprops){...if (nextprops.params.id != this.props.params.id) {this.fetch(nextprops.params.id)};
}