Skip to content

Latest commit

 

History

History
34 lines (22 loc) · 713 Bytes

useprovider.md

File metadata and controls

34 lines (22 loc) · 713 Bytes
description
Allows the host that instantiates this useProvider to become the context.

useProvider

This hook enables you to take control of the context from the component that instantiates useProvider, thus avoiding the need to instantiate the context node in the DOM.

Example of the useProvider hook:

import { createContext, useProvider, c } from "atomico";

export const Theme = createContext({
    color: "white",
    background: "black"
});

export const App = c(()=>{
    useProvider(Theme,{
        color: "red",
        background: "yellow"
    });
    
    return <host shadowDom><slot/></host>
});

Objective

Avoid creating an instantiable context node in the DOM.