@sodax/dapp-kit 2.0.0-rc.2 → 2.0.0-rc.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/dist/index.d.cts CHANGED
@@ -1478,13 +1478,20 @@ declare function useClaimRewards<K extends SpokeChainKey = SpokeChainKey>({ muta
1478
1478
  interface SodaxProviderProps {
1479
1479
  children: ReactNode;
1480
1480
  /**
1481
- * Sodax config (overrides defaults including rpcUrls). **Read-once at mount**
1482
- * changes after first render are ignored to prevent re-instantiating the SDK
1483
- * from unstable parent references. To switch config (e.g. testnet mainnet),
1484
- * unmount/remount the provider.
1481
+ * Sodax SDK config. Tracked by **reference** - a new identity re-instantiates the
1482
+ * SDK. Hoist to a module constant or wrap in `useMemo`; include any value the SDK
1483
+ * should react to (e.g. solver env) in the deps. Inline `{...}` re-creates the SDK
1484
+ * every parent render and resets every `useSodaxContext` consumer.
1485
+ *
1486
+ * @example
1487
+ * ```tsx
1488
+ * const config = useMemo(() => ({ solver: solverMap[env] }), [env]);
1489
+ * <SodaxProvider config={config}>...</SodaxProvider>
1490
+ * ```
1485
1491
  */
1486
1492
  config?: DeepPartial<SodaxConfig>;
1487
1493
  }
1494
+ /** Root provider for `@sodax/dapp-kit`. Must be paired with `QueryClientProvider`. */
1488
1495
  declare const SodaxProvider: ({ children, config }: SodaxProviderProps) => ReactElement;
1489
1496
 
1490
1497
  type CreateSodaxQueryClientOptions = {
package/dist/index.d.ts CHANGED
@@ -1478,13 +1478,20 @@ declare function useClaimRewards<K extends SpokeChainKey = SpokeChainKey>({ muta
1478
1478
  interface SodaxProviderProps {
1479
1479
  children: ReactNode;
1480
1480
  /**
1481
- * Sodax config (overrides defaults including rpcUrls). **Read-once at mount**
1482
- * changes after first render are ignored to prevent re-instantiating the SDK
1483
- * from unstable parent references. To switch config (e.g. testnet mainnet),
1484
- * unmount/remount the provider.
1481
+ * Sodax SDK config. Tracked by **reference** - a new identity re-instantiates the
1482
+ * SDK. Hoist to a module constant or wrap in `useMemo`; include any value the SDK
1483
+ * should react to (e.g. solver env) in the deps. Inline `{...}` re-creates the SDK
1484
+ * every parent render and resets every `useSodaxContext` consumer.
1485
+ *
1486
+ * @example
1487
+ * ```tsx
1488
+ * const config = useMemo(() => ({ solver: solverMap[env] }), [env]);
1489
+ * <SodaxProvider config={config}>...</SodaxProvider>
1490
+ * ```
1485
1491
  */
1486
1492
  config?: DeepPartial<SodaxConfig>;
1487
1493
  }
1494
+ /** Root provider for `@sodax/dapp-kit`. Must be paired with `QueryClientProvider`. */
1488
1495
  declare const SodaxProvider: ({ children, config }: SodaxProviderProps) => ReactElement;
1489
1496
 
1490
1497
  type CreateSodaxQueryClientOptions = {
package/dist/index.mjs CHANGED
@@ -2483,10 +2483,9 @@ function useClaimRewards({
2483
2483
  });
2484
2484
  }
2485
2485
  var SodaxProvider = ({ children, config }) => {
2486
- const configRef = useRef(config);
2487
- const frozen = configRef.current;
2488
- const sodax = useMemo(() => new Sodax(frozen), [frozen]);
2489
- return /* @__PURE__ */ jsx(SodaxContext.Provider, { value: { sodax }, children });
2486
+ const sodax = useMemo(() => new Sodax(config), [config]);
2487
+ const contextValue = useMemo(() => ({ sodax }), [sodax]);
2488
+ return /* @__PURE__ */ jsx(SodaxContext.Provider, { value: contextValue, children });
2490
2489
  };
2491
2490
  var defaultOnMutationError = (error) => {
2492
2491
  console.error("[sodax] Mutation error:", error);