我正在尝试将 TailwindCSS 与 SCSS 结合使用,但打开此文件时 VSCode 总是给我一条错误消息,我该如何修复它?
我在 postcss 文件中的配置:
module.exports = {
plugins: {
'postcss-import': {},
'tailwindcss/nesting': {},
tailwindcss: {},
autoprefixer: {},
},
};
Run Code Online (Sandbox Code Playgroud)
我在 VSCode settings.json 中的配置:
{
...
"css.lint.unknownAtRules": "ignore",
"css.lint.emptyRules": "ignore",
"scss.lint.unknownAtRules": "ignore",
"scss.lint.emptyRules": "ignore"
}
Run Code Online (Sandbox Code Playgroud)
我发现错误原因#{!important}
在 .scss 文件中
我用来useCallback
记录我的回调函数,但它似乎不适用于柯里化函数,尽管我将 PhotoItem 包装在 React.memo() 中,但我的组件在重新渲染PhotoItem
时总是重新渲染。MyListPhoto
因为handleDelete
function 是柯里化函数,所以有什么方法可以与 useCallback 一起使用吗?
const MyListPhoto = () => {
...other state...
const { delete } = useDeletePhoto();
// always create new function when component re-render
const handleDelete = useCallback((index) => (photoId) => {
delete(photoId, index)
}, []);
return (
<ul>
{photos.map((photo, index) => (
<PhotoItem
key={photo.id}
photo={photo}
onDelete={handleDelete(index)}
/>
))}
</ul>
)
}
Run Code Online (Sandbox Code Playgroud)
照片项目组件:
const PhotoItem = React.memo(({ photo, onDelete }) => {
console.log('re-render');
return (
... …
Run Code Online (Sandbox Code Playgroud)