- Fix the warning button can not be descendant of button

- Fix the warning possible change from uncontrolled to controlled component
This commit is contained in:
Shemy Gan committed 2024-12-12 09:58:11 -05:00
1 parent 9370db62cc
commit 00be6c219a
2 files changed
+15 -18

No files matched your search

@@ -2,22 +2,19 @@ import React, { useRef } from "react";
import { useDrag, useDrop } from "react-dnd"; import { useDrag, useDrop } from "react-dnd";
import ItemTypes from "./ItemTypes"; import ItemTypes from "./ItemTypes";
import Card from "@mui/material/Card"; import Card from "@mui/material/Card";
import CardActionArea from "@mui/material/CardActionArea";
import CardContent from "@mui/material/CardContent";
import Server from "./Server" import Server from "./Server"
import { CardContent } from "@mui/material";
const CustomCard = React.forwardRef((props, ref) => ( const CustomCard = React.forwardRef((props, ref) => (
<Card ref={ref}> <Card ref={ref}>
<CardActionArea> <CardContent>
<CardContent> <Server
<Server id={props.id}
id={props.id} removeItem={props.removeCard}
removeItem={props.removeCard} value={props.value}
value={props.value} onChange={props.onChange}
onChange={props.onChange} />
/> </CardContent>
</CardContent>
</CardActionArea>
</Card> </Card>
)); ));
@@ -68,7 +65,7 @@ const MyCard = ({ id, index, moveCard, removeCard, value, onChange }) => {
item.index = hoverIndex; item.index = hoverIndex;
} }
}); });
const [ {isDragging}, drag] = useDrag({ const [ _, drag] = useDrag({
type: ItemTypes.CARD, type: ItemTypes.CARD,
item: {id: id, index:index}, item: {id: id, index:index},
collect: monitor => ({ collect: monitor => ({
@@ -76,14 +73,14 @@ const MyCard = ({ id, index, moveCard, removeCard, value, onChange }) => {
}) })
}); });
drag(drop(ref)); drag(drop(ref));
return ( return (
<CustomCard <CustomCard
ref={ref} ref={ref}
id={id} id={id}
removeCard={removeCard} removeCard={removeCard}
value={value} value={value}
onChange={onChange} onChange={onChange}
/> />
); );
}; };
@@ -169,7 +169,7 @@ const ContentPanel = () => {
text={"" + idx} text={"" + idx}
moveCard={moveCard} moveCard={moveCard}
removeCard={removeCard} removeCard={removeCard}
value={card?.url} value={card?.url??""}
onChange = {handleCardChange} onChange = {handleCardChange}
/> />
))} ))}