-
Notifications
You must be signed in to change notification settings - Fork 47
Open
Description
Hello,
I'm trying to create a widget to know the last date of update of a component.
For this, I've create a new Widget using the Figma software:

And after, in my VSCode, I've copy the following code based on the https://github.com/figma/widget-samples/blob/main/WidgetDocumentChange/widget-src/code.tsx example.
const { widget } = figma
const { useSyncedState, AutoLayout, Text, useEffect } = widget
function Widget() {
const currentDateDefaultValue = 'XX/XX/XXXX'
const [currentDate, setCurrentDate] = useSyncedState('currentDate', currentDateDefaultValue);
useEffect(() => {
const onDocumentChange = (event: DocumentChangeEvent) => {
setCurrentDate('TA/TA/TATA');
};
figma.on('documentchange', onDocumentChange);
return () => {
figma.off('documentchange', onDocumentChange);
}
});
return (
<AutoLayout>
<Text fontSize={32} italic={true} width={375} horizontalAlignText={'left'}>
Updated: {currentDate}
</Text>
</AutoLayout>
)
}
widget.register(Widget);
But my onDocumentChange function is never called.
What I miss?
Regards,
Metadata
Metadata
Assignees
Labels
No labels