@khanacademy/wonder-blocks-core
Advanced tools
Comparing version 4.2.1 to 4.3.0
# @khanacademy/wonder-blocks-core | ||
## 4.3.0 | ||
### Minor Changes | ||
- 246a921d: NEW: `useForceUpdate` hook. This should rarely be used and likely only ever from other hooks. | ||
## 4.2.1 | ||
@@ -4,0 +10,0 @@ |
@@ -685,2 +685,21 @@ import _extends from '@babel/runtime/helpers/extends'; | ||
/** | ||
* Hook for forcing a component to update on demand. | ||
* | ||
* This is for use inside other hooks that do some advanced | ||
* trickery with storing state outside of React's own state | ||
* mechanisms. As such this should never be called directly | ||
* outside of a hook, and more often than not, is the wrong | ||
* choice for whatever you are trying to do. If in doubt, | ||
* don't use it. | ||
* | ||
* @returns {() => void} A function that forces the component to update. | ||
*/ | ||
const useForceUpdate = () => { | ||
const [, setState] = React.useState(false); | ||
const forceUpdate = React.useCallback(() => setState(state => !state), []); | ||
return forceUpdate; | ||
}; | ||
const { | ||
@@ -720,2 +739,2 @@ useContext, | ||
export { IDProvider, RenderStateRoot, server as Server, Text, UniqueIDProvider, View, WithSSRPlaceholder, addStyle, useUniqueIdWithMock, useUniqueIdWithoutMock }; | ||
export { IDProvider, RenderStateRoot, server as Server, Text, UniqueIDProvider, View, WithSSRPlaceholder, addStyle, useForceUpdate, useUniqueIdWithMock, useUniqueIdWithoutMock }; |
@@ -85,3 +85,3 @@ module.exports = | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 15); | ||
/******/ return __webpack_require__(__webpack_require__.s = 16); | ||
/******/ }) | ||
@@ -105,3 +105,3 @@ /************************************************************************/ | ||
const RenderState = __webpack_require__(17)({ | ||
const RenderState = __webpack_require__(18)({ | ||
Root: "root", | ||
@@ -578,3 +578,3 @@ Initial: "initial", | ||
} | ||
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(16))) | ||
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(17))) | ||
@@ -924,2 +924,30 @@ /***/ }), | ||
"use strict"; | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return useForceUpdate; }); | ||
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0); | ||
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); | ||
/** | ||
* Hook for forcing a component to update on demand. | ||
* | ||
* This is for use inside other hooks that do some advanced | ||
* trickery with storing state outside of React's own state | ||
* mechanisms. As such this should never be called directly | ||
* outside of a hook, and more often than not, is the wrong | ||
* choice for whatever you are trying to do. If in doubt, | ||
* don't use it. | ||
* | ||
* @returns {() => void} A function that forces the component to update. | ||
*/ | ||
const useForceUpdate = () => { | ||
const [, setState] = react__WEBPACK_IMPORTED_MODULE_0__["useState"](false); | ||
const forceUpdate = react__WEBPACK_IMPORTED_MODULE_0__["useCallback"](() => setState(state => !state), []); | ||
return forceUpdate; | ||
}; | ||
/***/ }), | ||
/* 15 */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return RenderStateRoot; }); | ||
@@ -970,3 +998,3 @@ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0); | ||
/***/ }), | ||
/* 15 */ | ||
/* 16 */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
@@ -1002,5 +1030,7 @@ | ||
/* harmony import */ var _components_render_state_root_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(14); | ||
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderStateRoot", function() { return _components_render_state_root_js__WEBPACK_IMPORTED_MODULE_8__["a"]; }); | ||
/* harmony import */ var _hooks_use_force_update_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(14); | ||
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "useForceUpdate", function() { return _hooks_use_force_update_js__WEBPACK_IMPORTED_MODULE_8__["a"]; }); | ||
/* harmony import */ var _components_render_state_root_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(15); | ||
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderStateRoot", function() { return _components_render_state_root_js__WEBPACK_IMPORTED_MODULE_9__["a"]; }); | ||
@@ -1016,4 +1046,6 @@ | ||
/***/ }), | ||
/* 16 */ | ||
/* 17 */ | ||
/***/ (function(module, exports) { | ||
@@ -1044,3 +1076,3 @@ | ||
/***/ }), | ||
/* 17 */ | ||
/* 18 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
@@ -1047,0 +1079,0 @@ |
{ | ||
"name": "@khanacademy/wonder-blocks-core", | ||
"version": "4.2.1", | ||
"version": "4.3.0", | ||
"design": "v1", | ||
@@ -5,0 +5,0 @@ "publishConfig": { |
@@ -15,4 +15,5 @@ // @flow | ||
} from "./hooks/use-unique-id.js"; | ||
export {useForceUpdate} from "./hooks/use-force-update.js"; | ||
export {RenderStateRoot} from "./components/render-state-root.js"; | ||
export type {AriaProps, IIdentifierFactory, StyleType}; |
238740
49
4523