Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort current state alphabetically #3

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Sort current state alphabetically
Łukasz Stefański committed Jun 15, 2022
commit 5f27a97056d67d94f88b3f1025057e31f30382d2
43 changes: 22 additions & 21 deletions chrome/panel.js

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion src/DevtoolsPanel/modules/CurrentState/CurrentState.jsx
Original file line number Diff line number Diff line change
@@ -25,9 +25,22 @@ const CurrentState = () => {
fetchStateListeners();
}, [fetchState, fetchStateListeners]);

const sortCurrentStateAlphabetically = useCallback(() => {
lukaszstefanski marked this conversation as resolved.
Show resolved Hide resolved
const alphabeticallySortedCurrentState = {};
Object.keys(currentState)
.sort()
.forEach((state) => {
Object.assign(alphabeticallySortedCurrentState, { [state]: currentState[state]})
});
return alphabeticallySortedCurrentState;
}, [currentState]);

const alphabeticallySortedCurrentState = sortCurrentStateAlphabetically();

useEffect(() => {
fetchAll()
}, [fetchAll]);

return (
<div className={styles.moduleContainer}>
<ModuleHeader icon={<StorageIcon fontSize="medium"/>} title="Current state">
@@ -38,7 +51,7 @@ const CurrentState = () => {
</ModuleHeader>
<div className={styles.moduleContent}>
<div className={styles.statePreview}>
<ObjectInspector data={currentState} />
<ObjectInspector data={alphabeticallySortedCurrentState} />
</div>
<div className={styles.stateListenersList}>
<h4>States that are listening</h4>