1

I use React DevTools Chrome Extension. I want to append component filters from a react app code. Is there a way to do this?

In common I want to share default application DevTools settings across the app developers.

enter image description here

dizel3d
  • 3,619
  • 1
  • 22
  • 35

1 Answers1

2

I figured out. Here's an example:

if (__REACT_DEVTOOLS_GLOBAL_HOOK__) {
  const handleReactDevtools = (agent) => {
    __REACT_DEVTOOLS_COMPONENT_FILTERS__.push({
      type: 2,
      isEnabled: true,
      isValid: true,
      value: "HideMe"
    });
    agent.updateComponentFilters(__REACT_DEVTOOLS_COMPONENT_FILTERS__);
  };
  if (__REACT_DEVTOOLS_GLOBAL_HOOK__.reactDevtoolsAgent) {
    handleReactDevtools(__REACT_DEVTOOLS_GLOBAL_HOOK__.reactDevtoolsAgent);
  } else {
    __REACT_DEVTOOLS_GLOBAL_HOOK__.on("react-devtools", handleReactDevtools);
  }
}

DevTools interop example

dizel3d
  • 3,619
  • 1
  • 22
  • 35