useContext
Since version Atomico@1.62.0 has introduced a context api as part of the core.
createContext
import { createContext } from "atomico";
export const Theme = createContext({
color: "white",
background: "black"
});
customElements.define( "my-theme", Theme );useContext
import { useContext } from "atomico";
import { Theme } from "./my-theme";
function card(){
const {color, background} = useContext(Theme);
return <host>
color: { color }
background: { background }
</host>
}Custom context values
When to use the Context API?
Last updated
Was this helpful?
