Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/valtio/src/vanilla/utils/proxyMap.ts>proxyMap

💊 Valtio makes proxy-state simple for React and Vanilla
Go to Latest
function proxyMap
import { proxyMap } from "https://deno.land/x/valtio@v2.0.0-beta.3/src/vanilla/utils/proxyMap.ts";

proxyMap

This is to create a proxy which mimic the native Map behavior. The API is the same as Map API

Examples

import { proxyMap } from 'valtio/utils' const state = proxyMap([["key", "value"]])

//can be used inside a proxy as well const state = proxy({ count: 1, map: proxyMap() })

// When using an object as a key, you can wrap it with ref so it's not proxied // this is useful if you want to preserve the key equality import { ref } from 'valtio'

const key = ref({}) state.set(key, "value") state.get(key) //value

const key = {} state.set(key, "value") state.get(key) //undefined

Parameters

optional
entries: Iterable<readonly [K, V]> | null