setAllTODOS([...sortedTodos]);
setAllTODOS((prevTodos) => [...sortedTodos]);
export const AuthContext = createContext({})
<AuthContext.Provider value={{currentUser, setCurrentUser}}> // тут нельзя использовать квадратные скобки при передаче значения
const {currentUser, setCurrentUser} = useContext(AuthContext) // тут нельзя использовать квадратные скобки при деструктуризации
export const AuthContext = createContext([])
<AuthContext.Provider value={[currentUser, setCurrentUser]}> // тут нельзя использовать фигурные скобки при передаче значения
const [currentUser, setCurrentUser] = useContext(AuthContext) // тут нельзя использовать фигурные скобки при деструктуризации
import {
createContext,
useContext,
useState,
type FC,
type Dispatch,
type SetStateAction,
} from "react";
type TAuthContext = [string | null, Dispatch<SetStateAction<string>> | null];
export const AuthContext = createContext<TAuthContext>([null, null]);
export const Form: FC = () => {
const [currentUser, setCurrentUser] = useContext(AuthContext);
return <>1</>;
};
export const App: FC = () => {
const [currentUser, setCurrentUser] = useState<string | null>(null);
return (
<>
<AuthContext.Provider value={[currentUser, setCurrentUser]}>
<Form />
</AuthContext.Provider>
</>
);
};
<li
{...sort}
>
<li
name={sort.name}
>
const {sortProperty, ...rest} = sort;
<li
{...rest}
>
const updateSearch: ChangeEventHandler<HTMLInputElement> = (event) => {};
или
const updateSearch = (event: ChangeEvent<HTMLInputElement>) => {};
onChange?: ChangeEventHandler<T> | undefined;
setMatched(findInput.matchFound.sort((first, second) => first.price[0] - second.price[0]));
setMatched([...findInput.matchFound.sort((first, second) => first.price[0] - second.price[0])]);
import { FC, useRef } from "react";
const data: { id: number; name: string }[] = [
{
id: 1,
name: "Первый"
},
{
id: 13,
name: "Тринадцатый"
},
{
id: 20,
name: "Двадцатый"
}
];
const App: FC = () => {
const divRef = useRef<HTMLDivElement>(null);
console.log(divRef.current);
return (
<>
{data.map((item) => (
<div ref={item.id === 13 ? divRef : undefined} key={item.id}>
{item.name}
</div>
))}
</>
);
};
export default App;
const [email, setEmail] = useState("")
const [password, setPassword] = useState("")
import React from "react";
import { Products } from "../Products";
class Main extends React.Component {
state = {
products: [],
};
componentDidMount() {
fetch("./products.json")
.then((responce) => responce.json())
.then((data) => this.setState({ products: Object.values(data) }));
}
render() {
const { products } = this.state;
return (
<main className="container content">
<Products products={products} />
</main>
);
}
}
export { Main };
class OurCoffee extends Component {
constructor(props) {
super(props);
this.state = {
data: [
{ name: "AROMISTICO Coffee 1 kg", country: "Brazil", price: 6.99 },
{ name: "AROMISTICO Coffee 1 kg", country: "Kenya", price: 6.99 },
{ name: "AROMISTICO Coffee 1 kg", country: "Columbia", price: 6.99 }
],
term: ""
};
}
commitInputChanges = (e) => {
this.setState({ term: e.target.value });
};
render() {
const { data, term } = this.state;
return (
<div>
<div className="filter">
<div className="filter_first">
<h2>Looking for</h2>
<input
type="text"
placeholder="start typing here"
onChange={this.commitInputChanges}
/>
</div>
</div>
{data
.filter((item) =>
item.country.toLowerCase().includes(term.toLowerCase())
)
.map((item) => (
<div key={item.country} className="product">
<img src={"coffee"} alt="" />
<h2 className="item_name">{item.name}</h2>
<h2 className="item_from">{item.country}</h2>
<h2 className="item_price">{item.price}</h2>
</div>
))}
</div>
);
}
}
export default OurCoffee;
handleChangeInfoMain: (value: string) => void