Update formState when links change
This commit is contained in:
parent
168b3879af
commit
68f012ba62
|
@ -1,4 +1,4 @@
|
|||
import React, { useState } from "react";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { DragDropContext, Droppable, DropResult } from "react-beautiful-dnd";
|
||||
import Link, { EditableLink } from "components/Editor/Link";
|
||||
|
||||
|
@ -10,10 +10,14 @@ interface EditorProps {
|
|||
setLinks: React.Dispatch<React.SetStateAction<EditableLink[]>>;
|
||||
}
|
||||
|
||||
const Editor: React.FC<EditorProps> = ({ links, setLinks }) => {
|
||||
const Editor: React.FC<EditorProps> = ({ links }) => {
|
||||
const [formState, setFormState] = useState<EditableLink[]>(links);
|
||||
const { displayDragDrop } = useDragDrop();
|
||||
|
||||
useEffect(() => {
|
||||
setFormState(links);
|
||||
}, [links]);
|
||||
|
||||
const handleOnDragEnd = (result: DropResult) => {
|
||||
if (!result?.destination) return;
|
||||
|
||||
|
|
Loading…
Reference in New Issue