You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
React higher order component to provide UI state for components.
3
+
4
+
## Problems this is trying reduce
5
+
- Reduce the need to reach for `setState` to save time for simple flags
6
+
- Reduce reducer boilerplate for properties like UI flags
7
+
- Reduce tediousness of instances of the same component needing the same flags
8
+
9
+
## How it works
10
+
- Create a config object with an optional name property and a function (which gets passed props) which returns a state object consisting of your initial state.
11
+
- Wrap your component in the HOC.
12
+
- An action gets dispatched like `UI_STATE_ADD:some-component_<uuid>`
13
+
- The initial state gets added to a `uiState` slice of the store with the name/state.
14
+
- Call `setUiState` with a new state object.
15
+
- An action gets dispatched like `UI_STATE_SET:some-component_<uuid>`
16
+
17
+
Simple update function, same as React's `setState`.
function_classCallCheck(instance,Constructor){if(!(instanceinstanceofConstructor)){thrownewTypeError("Cannot call a class as a function");}}
26
+
27
+
function_possibleConstructorReturn(self,call){if(!self){thrownewReferenceError("this hasn't been initialised - super() hasn't been called");}returncall&&(typeofcall==="object"||typeofcall==="function") ? call : self;}
28
+
29
+
function_inherits(subClass,superClass){if(typeofsuperClass!=="function"&&superClass!==null){thrownewTypeError("Super expression must either be null or a function, not "+typeofsuperClass);}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor: {value: subClass,enumerable: false,writable: true,configurable: true}});if(superClass)Object.setPrototypeOf ? Object.setPrototypeOf(subClass,superClass) : subClass.__proto__=superClass;}
0 commit comments