When I try to get async storage item using react-native-async-storage/async-storage from the widget handler,
the widget can not be resized and updated.
I could show my codes you read.
import React from 'react';
import { HelloWidget } from './HelloWidget';
import useStore from './store';
const nameToWidget = {
// Hello will be the **name** with which we will reference our widget.
Hello: HelloWidget,
};
export async function widgetTaskHandler(props) {
const widgetInfo = props.widgetInfo;
const Widget = nameToWidget[widgetInfo.widgetName];
const { getAsyncItem } = useStore(s => s);
const text= await getAsyncItem('text');
switch (props.widgetAction) {
case 'WIDGET_ADDED':
props.renderWidget(<Widget text={text} />);
break;
case 'WIDGET_UPDATE':
props.renderWidget(<Widget text={text} />);
break;
case 'WIDGET_RESIZED':
props.renderWidget(<Widget text={text} />);
break;
case 'WIDGET_DELETED':
// Not needed for now
break;
case 'WIDGET_CLICK':
// Not needed for now
break;
default:
break;
}
}
I think there's a solution that I didn't think of.
Hello.
I enjoy your package, but there's a problem.
When I try to get async storage item using react-native-async-storage/async-storage from the widget handler, the widget can not be resized and updated.
I could show my codes you read.
I think there's a solution that I didn't think of.
How to get saved data from widget?
I will wait for your answer.
Thanks.