mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-07-22 14:09:46 +03:00
run prettier
This commit is contained in:
parent
4574eb0c62
commit
a4aac76d5a
|
@ -122,9 +122,12 @@ export default function JSONNestedNode(props: Props) {
|
|||
? false
|
||||
: (function getDefault() {
|
||||
switch (shouldExpandNode) {
|
||||
case 'expand': return true;
|
||||
case 'collapse': return false;
|
||||
default: return shouldExpandNodeInitially(keyPath, data, level);
|
||||
case 'expand':
|
||||
return true;
|
||||
case 'collapse':
|
||||
return false;
|
||||
default:
|
||||
return shouldExpandNodeInitially(keyPath, data, level);
|
||||
}
|
||||
})()
|
||||
);
|
||||
|
@ -134,21 +137,27 @@ export default function JSONNestedNode(props: Props) {
|
|||
/**
|
||||
* Used the useRef to handle expanded because calling a setState in a recursive implementation
|
||||
* could lead to a "Maximum update depth exceeded" error */
|
||||
const expandedRef = useRef<boolean>(defaultExpanded)
|
||||
const expandedRef = useRef<boolean>(defaultExpanded);
|
||||
|
||||
switch (shouldExpandNode) {
|
||||
case 'expand': expandedRef.current = isCircular ? false : true; break;
|
||||
case 'collapse': expandedRef.current = false; break;
|
||||
case 'default': expandedRef.current = defaultExpanded; break;
|
||||
case 'expand':
|
||||
expandedRef.current = isCircular ? false : true;
|
||||
break;
|
||||
case 'collapse':
|
||||
expandedRef.current = false;
|
||||
break;
|
||||
case 'default':
|
||||
expandedRef.current = defaultExpanded;
|
||||
break;
|
||||
default: //Do nothing;
|
||||
}
|
||||
|
||||
const handleClick = useCallback(() => {
|
||||
if (expandable) {
|
||||
expandedRef.current = !expandedRef.current
|
||||
setTriggerReRender((e) => !e)
|
||||
expandedRef.current = !expandedRef.current;
|
||||
setTriggerReRender((e) => !e);
|
||||
setEnableDefaultButton(true);
|
||||
setShouldExpandNode(undefined)
|
||||
setShouldExpandNode(undefined);
|
||||
}
|
||||
}, [expandable, setEnableDefaultButton, setShouldExpandNode]);
|
||||
|
||||
|
@ -169,7 +178,12 @@ export default function JSONNestedNode(props: Props) {
|
|||
createItemString(data, collectionLimit),
|
||||
keyPath
|
||||
);
|
||||
const stylingArgs = [keyPath, nodeType, expandedRef.current, expandable] as const;
|
||||
const stylingArgs = [
|
||||
keyPath,
|
||||
nodeType,
|
||||
expandedRef.current,
|
||||
expandable,
|
||||
] as const;
|
||||
|
||||
return hideRoot ? (
|
||||
<li {...styling('rootNode', ...stylingArgs)}>
|
||||
|
|
|
@ -24,7 +24,11 @@ interface Props {
|
|||
|
||||
const ExpandableButtonsContext = createContext<Context>({} as Context);
|
||||
|
||||
function ExpandableButtonsContextProvider({ expandable, children, styling }: Props) {
|
||||
function ExpandableButtonsContextProvider({
|
||||
expandable,
|
||||
children,
|
||||
styling,
|
||||
}: Props) {
|
||||
const [enableDefaultButton, setEnableDefaultButton] = useState(false);
|
||||
const [shouldExpandNode, setShouldExpandNode] = useState();
|
||||
|
||||
|
@ -41,7 +45,9 @@ function ExpandableButtonsContextProvider({ expandable, children, styling }: Pro
|
|||
return (
|
||||
<ExpandableButtonsContext.Provider value={value}>
|
||||
{children}
|
||||
{expandable && <ExpandableButtons expandable={expandable} styling={styling} />}
|
||||
{expandable && (
|
||||
<ExpandableButtons expandable={expandable} styling={styling} />
|
||||
)}
|
||||
</ExpandableButtonsContext.Provider>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ describe('JSONTree', () => {
|
|||
const result = render(<JSONTree data={BASIC_DATA} />);
|
||||
|
||||
expect(result.type).toBe('ul');
|
||||
expect(result.props.children.type.name).toBe(ExpandableButtonsContextProvider.name);
|
||||
expect(result.props.children.type.name).toBe(
|
||||
ExpandableButtonsContextProvider.name
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user