function dataPage() {
fetch('example.com')
.then(response => response.json())
.then(data => {
const promises = data.URLs.map(url => fetch(url).then(r => r.json()))
return Promise.all(promises).then((arr) => {
data.arr = arr;
return data;
})
})
.then((data) => {
setState(prevState => {
return (
{
...prevState,
data // вероятно тут спред нужен по логике
}
)
})
})
}
css={`класс`}
выглядит, как emotion css prop. const root = document.getElementById('root');
function writeText(text, delay) {
if (!text) {
return;
}
const char = text[0];
const remaining = text.slice(1);
setTimeout(() => {
root.textContent = root.textContent + char;
writeText(remaining, delay);
}, delay);
}
function run() {
writeText('hello world', 50);
}
someAwesomeFunction= (arg1) => {
let data = JSON.stringify({
"arg1": arg1,
})
// Send a POST request
return axios({
method: 'post',
url: awesomeUrl,
data: data,
headers: {
"Content-Type": "application/json"
}
}).then((response) => {
console.log(response.status) ##вот здесь печатает статус код
return (response.status)
})
.catch((error) => {
console.log(error)
return 500
})}
// вариант 1
handleClick = async () => {
let response = await this.props.someAwesomeFunction(this.props.arg)
console.log(response) ######вот здесь получаю undefined
}
// вариант 2
handleClick = () => {
this.props.someAwesomeFunction(this.props.arg).then(response => {
console.log(response);
});
}
const rootElement = document.getElementById("root");
render(
<BrowserRouter>
<Routes>
<Route path="/" element={<App />}>
<Route path="expenses" element={<Expenses />} />
<Route path="invoices" element={<Invoices />} />
</Route>
</Routes>
</BrowserRouter>,
rootElement
);
import { Outlet, Link } from "react-router-dom";
export default function App() {
return (
<div>
<h1>Bookkeeper</h1>
<nav
style={{
borderBottom: "solid 1px",
paddingBottom: "1rem"
}}
>
<Link to="/invoices">Invoices</Link> |{" "}
<Link to="/expenses">Expenses</Link>
</nav>
<Outlet />
</div>
);
}
class Foo {
foo = 5;
bar = () => {
console.log(this.foo);
};
}
// вспомогательные функции вырезаны из ответа для упрощения
var Foo = function Foo() {
var _this = this;
_classCallCheck(this, Foo);
_defineProperty(this, "bar", function () {
console.log(_this.foo);
});
this.foo = 5;
};
USB 3.2, released in September 2017, replaces the USB 3.1 standard. It preserves existing USB 3.1 SuperSpeed and SuperSpeed+ data modes and introduces two new SuperSpeed+ transfer modes over the USB-C connector using two-lane operation, with data rates of 10 and 20 Gbit/s (1 and ~2.4 GB/s).