cogsbox-state 0.5.404 → 0.5.405

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cogsbox-state",
3
- "version": "0.5.404",
3
+ "version": "0.5.405",
4
4
  "description": "React state management library with form controls and server sync",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/CogsState.tsx CHANGED
@@ -1882,10 +1882,18 @@ function createProxyHandler<T>(
1882
1882
  }, [range.startIndex, range.endIndex, sourceArray, totalCount]);
1883
1883
 
1884
1884
  // Handle auto-scroll to bottom
1885
+ const [hasMounted, setHasMounted] = useState(false);
1886
+
1887
+ // Add this effect to track mounting:
1888
+ useEffect(() => {
1889
+ setHasMounted(true);
1890
+ }, []);
1891
+
1892
+ // Replace the auto-scroll effect with this version:
1885
1893
  useEffect(() => {
1886
1894
  if (!stickToBottom || !containerRef.current || totalCount === 0)
1887
1895
  return;
1888
- if (!shouldStickToBottomRef.current) return;
1896
+ if (!shouldStickToBottomRef.current && hasMounted) return; // Only check shouldStickToBottom after mount
1889
1897
 
1890
1898
  // Clear any existing interval
1891
1899
  if (scrollToBottomIntervalRef.current) {
@@ -1921,7 +1929,7 @@ function createProxyHandler<T>(
1921
1929
  const isAtBottom = actualBottom - currentBottom < 5;
1922
1930
 
1923
1931
  console.log(
1924
- `Scroll attempt ${attempts}: currentBottom=${currentBottom}, actualBottom=${actualBottom}, isAtBottom=${isAtBottom}`
1932
+ `Scroll attempt ${attempts}: currentBottom=${currentBottom}, actualBottom=${actualBottom}, isAtBottom=${isAtBottom}, hasMounted=${hasMounted}`
1925
1933
  );
1926
1934
 
1927
1935
  if (isAtBottom || attempts >= maxAttempts) {
@@ -1943,7 +1951,7 @@ function createProxyHandler<T>(
1943
1951
  scrollToBottomIntervalRef.current = null;
1944
1952
  }
1945
1953
  };
1946
- }, [totalCount, stickToBottom]);
1954
+ }, [totalCount, stickToBottom, hasMounted]);
1947
1955
 
1948
1956
  // Handle user scroll
1949
1957
  useEffect(() => {