@refinedev/core 4.5.2 → 4.5.3

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": "@refinedev/core",
3
- "version": "4.5.2",
3
+ "version": "4.5.3",
4
4
  "description": "refine is a React-based framework for building internal tools, rapidly. It ships with Ant Design System, an enterprise-level UI toolkit.",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
@@ -246,11 +246,16 @@ export const useForm = <
246
246
  // id state is needed to determine selected record in a context for example useModal
247
247
  const [id, setId] = React.useState<BaseKey | undefined>(defaultId);
248
248
 
249
+ /**
250
+ * In some cases, `id` from the router params is not available at the first render.
251
+ *
252
+ * (e.g. when using `Next.js` and client-side-rendering, `router` is not ready to use at the first render)
253
+ *
254
+ * We're watching for `defaultId` changes and setting `id` state if it's not equal to `defaultId`.
255
+ */
249
256
  React.useEffect(() => {
250
- if (defaultId !== id) {
251
- setId(idFromProps);
252
- }
253
- }, [idFromProps]);
257
+ setId(defaultId);
258
+ }, [defaultId]);
254
259
 
255
260
  /** `resourceName` fallback value depends on the router type */
256
261
  const resourceName =
@@ -108,9 +108,7 @@ export const useShow = <
108
108
  const [showId, setShowId] = useState<BaseKey | undefined>(defaultId);
109
109
 
110
110
  React.useEffect(() => {
111
- if (defaultId !== showId) {
112
- setShowId(defaultId);
113
- }
111
+ setShowId(defaultId);
114
112
  }, [defaultId]);
115
113
 
116
114
  /** `resourceName` fallback value depends on the router type */