Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

usecontext hook

import React, { useContext } from "react";
import ColorContext from "./colorcontex.ts";

const MyComponent = () => {
  const colors = useContext(ColorContext);

  return <div style={{ backgroundColor: colors.blue }}>...</div>;
};import React, { useContext } from "react";

const MyComponent = () => {
  const colors = useContext(ColorContext);

  return <div style={{ backgroundColor: colors.blue }}>...</div>;
};
Source by github.com #
 
PREVIOUS NEXT
Tagged: #usecontext #hook
ADD COMMENT
Topic
Name
9+4 =