- Create file in
components/directory:
// components/NewComponent.tsx
'use client';
interface NewComponentProps {
// Define props
}
export default function NewComponent({ }: NewComponentProps) {
return (
<div>
{/* Component content */}
</div>
);
}- Import in parent component:
import NewComponent from '@/components/NewComponent';- Add to appropriate file in
lib/:
// lib/jsonUtils.ts
/**
* Brief description
* @param param - Description
* @returns Description
*/
export function newUtility(param: string): string {
// Implementation
return result;
}- Use in components:
import { newUtility } from '@/lib/jsonUtils';- Add to
lib/types.ts:
export interface NewType {
property: string;
}- Import where needed:
import { NewType } from '@/lib/types';- Check
validateJson()return value - Look for trailing commas
- Verify quotes around keys and strings
- Check for comments (not valid JSON)
- Verify
rootNodeis not null - Check
jsonToTree()output - Inspect
expandedPathsstate - Look for React key warnings
- Verify
searchTree()returns matches - Check
getParentPaths()output - Confirm
expandedPathsis updated - Look for case sensitivity issues
- Check browser console for errors
- Verify HTTPS (clipboard API requires secure context)
- Test fallback mechanism
- Check clipboard permissions
const [newState, setNewState] = useState<Type>(initialValue);useEffect(() => {
// Effect code
return () => {
// Cleanup (optional)
};
}, [dependencies]);const handleClick = () => {
// Handle click
};
<button onClick={handleClick}>Click</button>{condition && <Component />}
{condition ? <ComponentA /> : <ComponentB />}{items.map((item, index) => (
<Component key={item.id || index} data={item} />
))}bg-gray-900- Dark backgroundtext-gray-100- Light textborder-gray-700- Borderstext-blue-400- Pathstext-green-400- Stringstext-yellow-400- Arrays
flex flex-col- Column layoutflex-1- Grow to fill spacegap-2- Spacing between itemsp-3- Paddingh-full- Full height
hover:bg-gray-800- Hover effectcursor-pointer- Pointer cursortransition-colors- Smooth transitions
- Paste valid JSON
- Paste invalid JSON (check error)
- Upload .json file
- Click to expand/collapse
- Click leaf value (copy path)
- Search for key
- Clear search
- Copy path button
- Copy value button
- Share button
- Load shared URL
{
"user": {
"name": "John Doe",
"age": 30,
"active": true,
"metadata": null
},
"orders": [
{
"id": 1,
"items": [
{ "product": "Widget", "price": 9.99 },
{ "product": "Gadget", "price": 19.99 }
],
"total": 29.98
}
]
}- Use
useMemofor expensive computations - Consider virtual scrolling for long lists
- Debounce search input
- Lazy load tree nodes
const searchResults = useMemo(() => {
return searchTree(rootNode, searchTerm);
}, [rootNode, searchTerm]);- Read README.md
- Read PRODUCT.md (Architecture section)
- Run the app and test features
- Read
app/page.tsx(main file)
- Read each component file
- Trace a click event from UI to state
- Modify a button label (small change)
- Add a console.log to see data flow
- Read
lib/jsonUtils.ts - Test
jsonToTree()with sample JSON - Modify
formatValueDisplay()(e.g., change "Array(5)" format) - Add a new utility function
- Pick from "Easy" enhancements (see PRODUCT.md)
- Plan the changes needed
- Implement step-by-step
- Test thoroughly
- Check documentation: README.md β PRODUCT.md β Code comments
- Search codebase: Use VS Code search for examples
- Test in isolation: Copy utility function to separate file and test
- Add console.logs: Debug state and props
- Ask questions: Better to ask than guess!
Ctrl/Cmd + P- Quick file openCtrl/Cmd + Shift + F- Search in filesF12- Go to definitionAlt + Click- Multi-cursorCtrl/Cmd + D- Select next occurrence
Keep this file handy for quick reference during development!