|
@@ -1,107 +1,26 @@
|
|
|
-import React from "react";
|
|
|
-import logo from "./logo.svg";
|
|
|
-import "./App.css";
|
|
|
+import React, { Component } from "react";
|
|
|
|
|
|
-import * as styles from "./mod.module.css";
|
|
|
-// const Children = props => {
|
|
|
-// console.log("props.", props);
|
|
|
-// return props.flag ? <div>Hello</div> : <div>World</div>;
|
|
|
-// };
|
|
|
+import Layuot from "./layout";
|
|
|
+import Header from "./header";
|
|
|
+import HideBlock from "./hideBlock";
|
|
|
+import Button from "./button";
|
|
|
|
|
|
-const Children2 = props => {
|
|
|
- console.log("props.", props);
|
|
|
- return props.children;
|
|
|
-};
|
|
|
+export class App extends Component {
|
|
|
+ state = { showBlock: false };
|
|
|
|
|
|
-const Aux = props => props.children;
|
|
|
+ handler = () => this.setState(prevState => ({ showBlock: !prevState.showBlock }));
|
|
|
|
|
|
-const Children = props => {
|
|
|
- console.log(props);
|
|
|
- return (
|
|
|
- <>
|
|
|
- <h4>Hello</h4>
|
|
|
- <p>World</p>
|
|
|
- </>
|
|
|
- );
|
|
|
-};
|
|
|
+ render() {
|
|
|
+ const { showBlock } = this.state;
|
|
|
+ // return (
|
|
|
+ // <div className="container">
|
|
|
+ // <Header toggle={this.handler} />
|
|
|
+ // {showBlock && <HideBlock />}
|
|
|
|
|
|
-function SuccessMessage() {
|
|
|
- return <Children type="success" header="Поздравляем!" text="Вы успешно зарегистрированы" />;
|
|
|
-}
|
|
|
-
|
|
|
-function SuccessMessage2() {
|
|
|
- const props = { type: "fail", header: "Не поздравляем!", text: "Вы успешно НЕ зарегистрированы" };
|
|
|
- return <Children {...props} type="success" />;
|
|
|
-}
|
|
|
+ // <Button text={!showBlock ? "show" : "hide"} onClick={this.handler} />
|
|
|
+ // </div>
|
|
|
+ // );
|
|
|
|
|
|
-const random = () => {
|
|
|
- const num = Math.floor(Math.random() * 10 + 1);
|
|
|
-
|
|
|
- switch (num) {
|
|
|
- case 3: {
|
|
|
- return "its 3";
|
|
|
- }
|
|
|
- case 6: {
|
|
|
- return "its 6";
|
|
|
- }
|
|
|
- case 8: {
|
|
|
- return "its 8";
|
|
|
- }
|
|
|
- default:
|
|
|
- return " default";
|
|
|
+ return <Layuot footer>{showBlock && <HideBlock />}</Layuot>;
|
|
|
}
|
|
|
-};
|
|
|
-
|
|
|
-const MyButton = ({ text, ...rest }) => <button {...rest}>{text}</button>;
|
|
|
-
|
|
|
-function User(props) {
|
|
|
- return <li>{props.user.name}</li>;
|
|
|
-}
|
|
|
-
|
|
|
-function UserList() {
|
|
|
- const users = [{ id: 1, name: "Вася", ban: true }, { id: 2, name: "Петя", ban: false }];
|
|
|
- return (
|
|
|
- <ul>
|
|
|
- {users.map(
|
|
|
- user =>
|
|
|
- !user.ban && (
|
|
|
- <React.Fragment key={user.id}>
|
|
|
- <User user={user} />
|
|
|
- </React.Fragment>
|
|
|
- )
|
|
|
- )}
|
|
|
- </ul>
|
|
|
- );
|
|
|
}
|
|
|
-const users = [{ id: 1, name: "Вася" }, { id: 2, name: "Петя" }];
|
|
|
-function App() {
|
|
|
- const lol = users.map(user => (
|
|
|
- // <User key={user.id} user={user} />
|
|
|
- <li>{user.name}</li>
|
|
|
- ));
|
|
|
- return (
|
|
|
- <div className="App">
|
|
|
- <header className="App-header">
|
|
|
- <img src={logo} className="App-logo" alt="logo" />
|
|
|
- <p>
|
|
|
- Edit <code>src/App.js</code> and save to reload.
|
|
|
- </p>
|
|
|
- <a className="App-link" href="https://reactjs.org" target="_blank" rel="noopener noreferrer">
|
|
|
- Learn React
|
|
|
- {/* <Children foo={random()} foo2={`asdsada`} /> */}
|
|
|
- <Children />
|
|
|
- {/* <SuccessMessage />
|
|
|
- <SuccessMessage2 /> */}
|
|
|
- {/* <Children2> */}
|
|
|
- {/* <SuccessMessage2 /> */}
|
|
|
- {/* </Children2> */}
|
|
|
- <UserList />
|
|
|
- <MyButton text="Click" type="submit" disabled />
|
|
|
- </a>
|
|
|
- </header>
|
|
|
- <div className={styles.dude}>Hello its my first meet with react</div>
|
|
|
- </div>
|
|
|
- );
|
|
|
-}
|
|
|
-
|
|
|
-export default App;
|