adamerose / muuri-react Goto Github PK
View Code? Open in Web Editor NEWThis project forked from paol-imi/muuri-react
The layout engine for React
Home Page: https://paol-imi.github.io/muuri-react/
License: MIT License
This project forked from paol-imi/muuri-react
The layout engine for React
Home Page: https://paol-imi.github.io/muuri-react/
License: MIT License
Hello I'm using this version of muuri for use a react 17.0.2
But i have simply code and i have error when i move grid between Muuri components:
Is in fresh app react
import { useState, useCallback } from "react";
import { MuuriComponent, useGrid } from "muuri-react";
function useSend(setItems) {
return useCallback(({ key, fromId, toId }) => {
fromId = fromId.toLowerCase();
toId = toId.toLowerCase();
setItems((items) => {
const newItems = { ...items };
newItems[fromId] = newItems[fromId].filter((item) => item !== key);
newItems[toId] = newItems[toId].concat(key);
return newItems;
});
}, [setItems]);
}
const columnOptions = {
// Enable to send the items in
// the grids with the following groupId.
dragSort: { groupId: "NOTES" },
groupIds: ["NOTES"],
containerClass: "board-column-content",
dragEnabled: true,
dragFixed: true,
dragSortHeuristics: {
sortInterval: 0,
},
dragContainer: document.body,
};
// App.
const App = () => {
// Items state.
const [items, setItems] = useState({
todo: ["4", "6", "5", "10"],
working: ["1", "3", "8"],
done: ["2", "7", "9"],
});
const onSend = useSend(setItems);
// Children.
const children = {
todo: items.todo.map((id) => <Item id={id} key={id} />),
done: items.done.map((id) => <Item id={id} key={id} />),
working: items.working.map((id) => <Item id={id} key={id} />),
};
const borderStyle = {
width: "100%",
height: "100px",
padding: "10px",
border: "2px dashed gray",
borderRadius: "5px",
overflowY: "scroll",
};
return (
<div>
<div style={borderStyle}>
Muuri Component 1
<MuuriComponent
id={"TODO"}
onSend={onSend}
sort={items.todo}
{...columnOptions}
>
{children.todo}
</MuuriComponent>
</div>
<div style={borderStyle}>
Muuri Component 2
<MuuriComponent
id={"WORKING"}
onSend={onSend}
sort={items.working}
{...columnOptions}
>
{children.working}
</MuuriComponent>
</div>
<div style={borderStyle}>
Muuri Component 3
<MuuriComponent
id={"DONE"}
onSend={onSend}
sort={items.done}
{...columnOptions}
>
{children.done}
</MuuriComponent>
</div>
</div>
);
};
const Item = ({ id }) => {
const gridId = useGrid().id.toLowerCase();
return (
<div className="board-item">
<div className="board-item-content">
<span>Item </span>
{`${id} - XXX`}
<div className={`tab-item ${gridId}-tab-item`} />
</div>
</div>
);
};
export default App;
The package.json is a fresh react app:
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"muuri-react": "github:adamerose/muuri-react",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"web-vitals": "^1.0.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Any idea if i'm doing wrong something? seems a muuri-react bug
Thank you for forking this and making it install compatible with React 17.
I get this error "You can only create one Muuri Item per element!" randomly even when then are no changes to the code, just with a file save and even after a full page refresh.
The error is originated from here muuri/src/Item/Item.js#L39 and it seems it's something new in muuri 0.9 to cache the items used.
I forked your repo and changed:
"peerDependencies": {
"muuri": "^0.8.0 || ^0.9.0",
"react": "^17.0.2"
},
to allow install muuri
0.8 and it seems like it's working fine so far without this issue.
I even looked at 0.8 code and there is no such mechanist nor that error thrown.
Do you have a clue how to fix this issue so to make it muuri
0.9 compatible?
The most strange part is that the error occurs even after a full page reload!
I think muuri-react
should install with muuri
0.8 until this issue gets sorted.
Since Paol-imi/muuri-react
is unmaintained, I took the changes made in https://github.com/Secretmapper/muuri-react/tree/strict-muuri-0.9
and merged them to master and fixed package.json on this fork. I will accept any new PRs made here.
The maintenance status of the original repo is discussed here: paol-imi#59
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.