I am trying to update tags after getting them from external url in github plugin zalify/easy-email
After user click preview it should update tags and change tags.
When I do it without async it is working fine example :
const onBeforePreview: EmailEditorProviderProps['onBeforePreview'] = useCallback(
(html: string, mergeTags) => {
const engine = new Liquid();
const tpl = engine.parse(html);
return engine.renderSync(tpl, mergeTags);
},
[],
)
but when I use async even without fetch it is not working.
const onBeforePreview: EmailEditorProviderProps['onBeforePreview'] = useCallback(
async (html: string, mergeTags): Promise<string> => {
const engine = new Liquid();
const tpl = engine.parse(html);
return await engine.renderSync(tpl, mergeTags);
},
[],
)
I think this is code part which handle the response by plugin PreviewEmailProvider/index.tsx
if (onBeforePreview) {
try {
const result = onBeforePreview(parseHtml, injectData);
if (isString(result)) {
parseHtml = result;
} else {
result.then((resHtml) => {
parseHtml = resHtml;
});
}
setErrMsg('');
} catch (error: any) {
setErrMsg(error?.message || error);
}
}
setHtml(parseHtml);
I tried return fetch or return Promise but it is not working too.
I’m not getting error in console but tags not update in preview.