tabler-react-2 0.1.104 → 0.1.106

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -116,21 +116,19 @@ Offcanvas.defaultProps = {
116
116
  };
117
117
  var useOffcanvas = exports.useOffcanvas = function useOffcanvas() {
118
118
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
119
- // Store the initial state in a memo so it doesn't change across renders
120
- var initialState = (0, _react.useMemo)(function () {
121
- return {
119
+ var _useState = (0, _react.useState)({
122
120
  show: false,
123
121
  resolve: null,
124
122
  content: options.content || null,
125
123
  position: options.position || "start"
126
- };
127
- }, [options.content, options.position]);
128
- var _useState = (0, _react.useState)(initialState),
124
+ }),
129
125
  _useState2 = _slicedToArray(_useState, 2),
130
126
  state = _useState2[0],
131
127
  setState = _useState2[1];
132
-
133
- // Open the offcanvas, optionally providing new content or position
128
+ var _useState3 = (0, _react.useState)(Math.random()),
129
+ _useState4 = _slicedToArray(_useState3, 2),
130
+ rand = _useState4[0],
131
+ setRand = _useState4[1];
134
132
  var offcanvas = (0, _react.useCallback)(function () {
135
133
  var newOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
136
134
  return new Promise(function (resolve) {
@@ -143,18 +141,20 @@ var useOffcanvas = exports.useOffcanvas = function useOffcanvas() {
143
141
  position: (_newOptions$position = newOptions.position) !== null && _newOptions$position !== void 0 ? _newOptions$position : prev.position
144
142
  });
145
143
  });
144
+ setRand(Math.random());
146
145
  });
147
146
  }, []);
148
-
149
- // Close the offcanvas and reset to the initial state
150
147
  var close = (0, _react.useCallback)(function () {
151
148
  if (state.resolve) {
152
149
  state.resolve();
153
150
  }
154
- setState(initialState);
155
- }, [state.resolve, initialState]);
156
-
157
- // The Offcanvas element to render
151
+ setState(function (prev) {
152
+ return _objectSpread(_objectSpread({}, prev), {}, {
153
+ show: false,
154
+ resolve: null
155
+ });
156
+ });
157
+ }, [state.resolve]);
158
158
  var OffcanvasElement = /*#__PURE__*/_react["default"].createElement(Offcanvas, _extends({
159
159
  show: state.show,
160
160
  onHide: close,
@@ -169,7 +169,9 @@ var useOffcanvas = exports.useOffcanvas = function useOffcanvas() {
169
169
  top: 10,
170
170
  right: 10
171
171
  }
172
- }), state.content);
172
+ }), /*#__PURE__*/_react["default"].createElement("div", {
173
+ key: rand
174
+ }, state.content));
173
175
  return {
174
176
  offcanvas: offcanvas,
175
177
  OffcanvasElement: OffcanvasElement,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tabler-react-2",
3
- "version": "0.1.104",
3
+ "version": "0.1.106",
4
4
  "description": "A react implementation of Tabler ui",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {