A debugging tool for Web applications that helps developers easily track and visualize state and event data in the development process.
- State and event tracking:
- Use
useDebugto monitor component state. - Use
debugto monitor events. - Use
debugStoreto monitorstoresfor nanostores.
- Use
- Developer-Friendly: Easy to integrate, no changes to your app's structure. No provider or context required.
npm install debug-shell@0.0.0-alpha.3.6 monaco-editor @monaco-editor/reactWrap your application with <DebugShell> to enable the debug shell as side panel:
import React from 'react';
import { DebugShell } from 'debug-shell';
function App() {
return (
<DebugShell>
<YourApp />
</DebugShell>
);
};Integrate the <DebugShell> as component in your app. You can place it anywhere in your app:
import React from 'react';
import { DebugShell } from 'debug-shell';
function App(){
return (
<div>
<YourApp />
<YourSidebar >
<DebugShell />
</YourSidebar>
</div>
);
};To monitor state, use the useDebug hook:
import React from 'react';
import { useDebug } from 'debug-shell';
function MyComponent() {
const userState = useState({
name: 'TestUser',
age: 23,
email: 'test@test.com',
});
useDebug('userState', userState);
return <p>Name: {userState.name}</p>;
};To monitor events, use the debugValue function:
import React from 'react';
import { debug } from 'debug-shell';
function MyComponent() {
const handleClick = (event) => {
debug('onClickEvent', event);
alert('Button clicked!');
};
return <button onClick={handleClick}>Click Me</button>;
};debugStore for store tracking from nanostores.
The debugStore function can be used outside of React components to register nanostores:
import { atom } from 'nanostores';
import { debugStore } from 'debug-shell';
const counterStore = atom({ count: 0 })
debugStore("counterStore", counterStore)
setInterval(() => {
counterStore.set({ count: counterStore.get().count + 1 })
}, 1e3)| Component | Description |
|---|---|
<DebugShell /> |
Debugging tool for tracking state and events. |
| API | Description |
|---|---|
debug |
Function for tracking events. |
debugStore |
Function for tracking nanostores. |
useDebug |
Hook for tracking state. |
