@fibery/react 3.1.5 → 3.1.6

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.
@@ -13,7 +13,7 @@ const hasChildren = (node) => isValidElement(node) && Boolean(node.props.childre
13
13
  const reactNodeToString = (node) => {
14
14
  if (!(node instanceof Array) && !isValidElement(node)) return nodeToString(node);
15
15
  return Children.toArray(node).reduce((text, child) => {
16
- let newText = "";
16
+ let newText;
17
17
  if (hasChildren(child)) newText = reactNodeToString(child.props.children);
18
18
  else if (isValidElement(child) && !hasChildren(child)) newText = "";
19
19
  else newText = nodeToString(child);
@@ -12,11 +12,12 @@ const useControllableState = ({ value, defaultValue, onChange }) => {
12
12
  const state = isControlled ? value : uncontrolledState;
13
13
  const prevUncontrolledStateRef = useRef(uncontrolledState);
14
14
  useEffect(() => {
15
- if (prevUncontrolledStateRef.current !== uncontrolledState) {
15
+ const previousState = prevUncontrolledStateRef.current;
16
+ if (previousState !== uncontrolledState && !Object.is(previousState, uncontrolledState)) {
16
17
  onChangeState(uncontrolledState);
17
18
  prevUncontrolledStateRef.current = uncontrolledState;
18
19
  }
19
- });
20
+ }, [uncontrolledState, onChangeState]);
20
21
  return [state, useCallback((nextValue) => {
21
22
  if (isControlled) {
22
23
  const nextState = nextValue instanceof Function ? nextValue(value) : nextValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/react",
3
- "version": "3.1.5",
3
+ "version": "3.1.6",
4
4
  "license": "UNLICENSED",
5
5
  "files": [
6
6
  "lib"
@@ -19,7 +19,7 @@
19
19
  }
20
20
  },
21
21
  "dependencies": {
22
- "@fibery/helpers": "7.0.0",
22
+ "@fibery/helpers": "7.1.0",
23
23
  "@tanstack/react-query": "5.107.1"
24
24
  },
25
25
  "peerDependencies": {