latticexyz / mud

MUD is a framework for building autonomous worlds
https://mud.dev
MIT License
754 stars 187 forks source link

use incrementing ID in react template #2253

Open holic opened 9 months ago

holic commented 9 months ago

Another rough edge I spotted when watching https://twitter.com/SolidityFridays/status/1755940653828354320

We teach people to think about MUD as a "relational data store" but then we do weird things in the React template like generate a random key from a hash of data including block.prevrandao. Although this might be the best approach from a Solidity perspective in terms of gas, etc., it doesn't help teach MUD using familiar concepts.

We could clarify this by another table that tracks an incrementing counter for using as the key when adding tasks. This has an added benefit of teaching about singleton tables.

RyRy79261 commented 9 months ago

One approach is you could offer a choice in the ... create mud script for recommended hash indexes, or incrementing ones.