我在node.js v15.0.1中看到过这种语法: &&=,||=和??=。但我不知道它有什么作用。有人知道吗?
我正在努力寻找使用Suspense和React hooks 的问题。
下面的 React 代码有几个关键问题。
import { Suspense, useState, useEffect } from 'react';
const SuspensefulUserProfile = ({ userId }) => {
const [data, setData] = useState({});
useEffect(() => {
fetchUserProfile(userId).then((profile) => setData(profile));
}, [userId, setData])
return (
<Suspense>
<UserProfile data={data} />
</Suspense>
);
};
const UserProfile = ({ data }) => {
return (
<>
<h1>{data.name}</h1>
<h2>{data.email}</h2>
</>
);
};
const UserProfileList = () => {
<>
<SuspensefulUserProfile userId={1} />
<SuspensefulUserProfile userId={2} /> …Run Code Online (Sandbox Code Playgroud) 大家好,我是 Tailwind 的新手。
我正在制作一个可见的下拉菜单,它位于表格单元格中,但它位于表格下方,不会溢出表格滚动条之外。我的桌子是一个水平滚动的桌子。我z-index尽可能多地给出下拉列表。但它不起作用。请帮忙。
TableBody.jsx
import React from 'react';
import _ from 'lodash';
import TableCell from './tableCell';
import Popup from './popup';
const popupItems = [{ label: 'Edit'}, { label: 'Delete' }];
const TableBody = ({
rows,
hiddenColumns,
checkedItems,
addCheckedItem,
removeCheckedItem,
}) => {
const handleToggle = (event, checkedItem) => {
if (event.target.checked) {
addCheckedItem(checkedItem);
} else {
removeCheckedItem(checkedItem);
}
};
return (
<tbody>
{rows.map((item, index) => (
<tr key={index} className="hover:bg-gray-100 cursor-pointer">
<td>
<div className="relative">
<Popup items={popupItems} />
</div> …Run Code Online (Sandbox Code Playgroud) 我的组件中有这些状态。
const [initialValues, setInitialValues] = useState({
name: "",
name2: "",
items: []
});
Run Code Online (Sandbox Code Playgroud)
name并name2组合在一起形成一个数组{name: 'sss', name2: 'sss'}并推送到该items数组。推动部分没问题。唯一的问题是谁删除该数组上的项目。
这是我的代码https://codesandbox.io/s/material-demo-forked-u2qzv?file=/demo.js:260-362
普通的数组方法在这里似乎不起作用。
如何修复 React 和 Formik?
javascript ×4
reactjs ×3
formik ×1
node.js ×1
operators ×1
react-hooks ×1
tailwind-css ×1
typescript ×1