我已经换行<ReactQueryDevtools />了<QueryClientProvider>,所以我不明白为什么我会遇到这个问题?
我查看了 TanStack 查询文档,但我不明白这个问题。
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import { BrowserRouter } from 'react-router-dom';
import { worker } from '@uidotdev/react-query-api';
import { QueryClient, QueryClientProvider } from 'react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
const queryClient = new QueryClient();
new Promise((res) => setTimeout(res, 100))
.then(() =>
worker.start({
quiet: true,
onUnhandledRequest: 'bypass',
})
)
.then(() => {
ReactDOM.render(
<React.StrictMode>
<QueryClientProvider client={queryClient}>
<BrowserRouter>
<div className="container">
<App />
</div> …Run Code Online (Sandbox Code Playgroud) function findLongestWordLength(str) {
let arr = str.split(' ');
let lengths = arr.map(word => word.length);
console.log(Math.max(lengths));
}
findLongestWordLength("The quick brown fox jumped over the lazy dog");
Run Code Online (Sandbox Code Playgroud)
console.log(Math.max(lengths))结果NaN,console.log(Math.Max(...lengths))有效。为什么需要扩展长度?Math.Max 采用数组作为参数,&lengths 是数组吗?谢谢