@uifabric/experiments
Version:
Experimental React components for building experiences for Microsoft 365.
18 lines • 999 B
JavaScript
import { __assign } from "tslib";
import { useCallback, useState } from 'react';
import { ImageLoadState } from 'office-ui-fabric-react';
export var usePersonaCoinState = function (props) {
// TODO: isPictureLoaded was controlled, does it need to be? it's not exposed through component props...
// For now use useState.
var _a = useState(false), isPictureLoaded = _a[0], setIsPictureLoaded = _a[1];
var onPhotoLoadingStateChange = props.onPhotoLoadingStateChange;
var _onPhotoLoadingStateChange = useCallback(function (newImageLoadState) {
if (onPhotoLoadingStateChange) {
onPhotoLoadingStateChange(newImageLoadState);
}
setIsPictureLoaded(newImageLoadState === ImageLoadState.loaded);
}, [onPhotoLoadingStateChange]);
var viewProps = __assign(__assign({}, props), { isPictureLoaded: isPictureLoaded, onPhotoLoadingStateChange: _onPhotoLoadingStateChange });
return viewProps;
};
//# sourceMappingURL=PersonaCoin.state.js.map