Answer the question
In order to leave comments, you need to log in
How to render different pages in ReactJS?
There is a code.
app.js
import React, { Component } from 'react';
//import logo from './logo.svg';
import './App.css';
import WorksheetSelector from './Worksheet_selector.js';
class App extends React.Component {
constructor(props) {
super();
this.state = {loadworksheep: false};
this.loadStuff = this.loadStuff.bind(this)
}
loadStuff() {
this.setState({loadWorksheep: true});
}
render() {
/* <div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h1 className="App-title">Welcome to React</h1>
</header>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>
</div> */
const startPage = (
<div className="App">
<h1>Первая страничка</h1>
<button onClick={this.loadStuff}>Начать</button>
</div>
);
const worksheetLoaderPage = (
WorksheetSelector
);
return (<div>{ this.state.loadworksheep ? worksheetLoaderPage : startPage }</div>);
}
}
export default App;
import React, { Component } from 'react';
import { render } from 'react-dom';
export default function WorksheetSelector(props) {
return (
<div>
<h1>Выберите группы</h1>
<button>Next step</button>
</div>
);
}
Answer the question
In order to leave comments, you need to log in
this.state = {loadworksheep: false};
this.setState({loadWorksheep: true});
w
should it be large or small? You would decide.const worksheetLoaderPage = (
WorksheetSelector
);
WorksheetSelector
---><WorksheetSelector />
If there is another way to render another page on button click, I'd be very glad to hear it.
If there is another way to render another page on button click, I'd be very glad to hear it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question