diff --git a/src/App.jsx b/src/App.jsx index c1dfb01..282e220 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,50 +1,78 @@ -import { useState, useReducer } from 'react' +import { useState, createContext, useContext } from 'react' +import styles from './App.module.scss' -function counterReducer(state, action) { - switch (action.type) { - case 'increment': - return state + 1 - case 'decrement': - return state - 1 - case 'reset': - return 0 - case 'set_value': - return action.value - default: - return state +const UserContext = createContext('') + +function UserProvider({ children }) { + const [name,setName] = useState(''); + + const toggleName = (newName) => { + setName(newName); } -} - -function Counter() { - const [count, dispatch] = useReducer(counterReducer,0); return ( -
- Счетчик: {count} - - - - + + {children} + + ) +} + +function Form() { + const {name, toggleName} = useContext(UserContext) + const [newName,setNewName] = useState(''); + const handleSubmit = (event) => { + event.preventDefault(); + toggleName(event.target[0].value) + } + const handlerChange = (event) => { + setNewName(event.target.value); + } + return ( +
+ + +
+ ) +} + +function ExitButton() { + const {name, toggleName} = useContext(UserContext) + + return ( + + ) +} + +function Toolbar() { + const {name, toggleName} = useContext(UserContext) + return( +
+

Панель пользователя

+ {name && `Привет ${name}`} + {name ? :
} +
) } -function App() { - const [tasks, setTasks] = useState([]) - const [filter, setFilter] = useState('all') - const [sortBy,setSortBy] = useState('date') - - const addTask = newTask => { - setTasks([...tasks,newTask]) - } - - +function Page() { + return ( +
+

Главная страница

+ +
+ ) +} + +function App() { return ( <> {/* Добавьте тестовый контент для проверки */}

Hello, React!

- + + + ) } diff --git a/src/App.module.scss b/src/App.module.scss index 5e617bc..974820c 100644 --- a/src/App.module.scss +++ b/src/App.module.scss @@ -1,10 +1,8 @@ .container { -/* display: flex; - flex-direction: column; - flex-wrap: nowrap;*/ height: 500px; - overflow: auto; border: 1px solid black; + border-radius: 10px; + background-color: lightblue; } .item { font-size: 16pt;