Skip to content

Latest commit

 

History

History
20 lines (17 loc) · 425 Bytes

InspectorContext.md

File metadata and controls

20 lines (17 loc) · 425 Bytes

InspectorContext

Inspector context

Syntax

function Widget() {
  const [ logging, toggle ] = useReducer(t => !t, false);
  const logger = useMemo(() => logging ? new ConsoleLogger() : null, [ logging ]);
  return (
    <div>
      <InspectorContext.Provider value={logger}>
        <AnotherWidget />
      </InspectorContext.Provider>
      <button onClick={toggle}>Toggle Logging</button>
    </div>
  );
}