Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

useMap.d.ts 883B

12345678910111213141516171819202122232425262728293031
  1. export declare class ObservableMap<K, V> extends Map<K, V> {
  2. private readonly listener;
  3. constructor(listener: (map: ObservableMap<K, V>) => void, init?: Iterable<Readonly<[K, V]>>);
  4. set(key: K, value: V): this;
  5. delete(key: K): boolean;
  6. clear(): void;
  7. }
  8. /**
  9. * Create and return a [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) that triggers rerenders when it's updated.
  10. *
  11. * ```tsx
  12. * const customerAges = useMap<number>([
  13. * ['john', 24],
  14. * ['betsy', 25]
  15. * ]);
  16. *
  17. * return (
  18. * <>
  19. * {Array.from(ids, ([name, age]) => (
  20. * <div>
  21. * {name}: {age}. <button onClick={() => ids.delete(name)}>X</button>
  22. * </div>
  23. * )}
  24. * </>
  25. * )
  26. * ```
  27. *
  28. * @param init initial Map entries
  29. */
  30. declare function useMap<K, V>(init?: Iterable<Readonly<[K, V]>>): ObservableMap<K, V>;
  31. export default useMap;