@uifabric/experiments
Version:
Experimental React components for building experiences for Microsoft 365.
20 lines • 1.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var react_1 = require("react");
var office_ui_fabric_react_1 = require("office-ui-fabric-react");
exports.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 = react_1.useState(false), isPictureLoaded = _a[0], setIsPictureLoaded = _a[1];
var onPhotoLoadingStateChange = props.onPhotoLoadingStateChange;
var _onPhotoLoadingStateChange = react_1.useCallback(function (newImageLoadState) {
if (onPhotoLoadingStateChange) {
onPhotoLoadingStateChange(newImageLoadState);
}
setIsPictureLoaded(newImageLoadState === office_ui_fabric_react_1.ImageLoadState.loaded);
}, [onPhotoLoadingStateChange]);
var viewProps = tslib_1.__assign(tslib_1.__assign({}, props), { isPictureLoaded: isPictureLoaded, onPhotoLoadingStateChange: _onPhotoLoadingStateChange });
return viewProps;
};
//# sourceMappingURL=PersonaCoin.state.js.map