Skip to content

Commit

Permalink
Remove dependency weak-key. Use path key to forcefully rerender when …
Browse files Browse the repository at this point in the history
…changed instead (#13)
  • Loading branch information
skrhlm authored Feb 3, 2022
1 parent 9f1266c commit 1a76967
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 44 deletions.
35 changes: 3 additions & 32 deletions packages/djedi-json/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions packages/djedi-json/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
},
"dependencies": {
"classnames": "^2.3.1",
"lodash-es": "^4.17.21",
"weak-key": "^1.0.2"
"lodash-es": "^4.17.21"
},
"peerDependencies": {
"react": ">=16.8.0",
Expand Down
14 changes: 4 additions & 10 deletions packages/djedi-json/src/core/Renderer/EditorTree.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import key from 'weak-key';

import { useCMS } from '../../contexts/cms';
import Editable from '../Editable';
Expand All @@ -22,21 +21,16 @@ const EditorTree: React.FC<{ tree: NodeTreeItem; path?: string[] }> = ({ tree, p
if (!Config) {
return null;
}
// const [childKey] = Object.entries(Config.content).find(([, t]) => t.type == 'input/children');

const { children } = tree.content;
// const localPath = [...path, index.toString(), 'content', 'children'];

return (
<Editable config={Config} tree={tree} path={path}>
{Array.isArray(children) &&
children?.map((child, i) => (
<EditorTree
tree={child}
key={key(child)}
path={[...path, 'content', 'children', i.toString()]}
/>
))}
children?.map((child, i) => {
const k = [...path, 'content', 'children', i.toString()];
return <EditorTree tree={child} key={k.join('.')} path={k} />;
})}
</Editable>
);

Expand Down

0 comments on commit 1a76967

Please sign in to comment.