near / react-on-chain

Improved execution layer for NEAR decentralized frontend components
https://roc-docs.near.dev/
23 stars 5 forks source link

fix: construct component IDs on demand #392

Closed andy-haynes closed 1 month ago

andy-haynes commented 1 month ago

This PR fixes component IDs for trusted Components. By combining the Component path (known at build time) and the Component key along with the path/key combinations for its ancestors traced up to the root Component. Currently this only gets set at the root container, which this change fixes by constructing the Component ID recursively at render time.

Current behavior: https://bos-web-engine.vercel.app/bwe-demos.near/StateAndTrust.Root?showContainerBoundaries=false Fixed behavior: https://bos-web-engine-git-fix-component-7c1578-near-developer-console.vercel.app/bwe-demos.near/StateAndTrust.Root?showContainerBoundaries=false

E.g. for this Component structure

<Parent key="p" bwe={{ trust: { mode: 'trusted-author' } }}>
  <Child key="c" />
</Parent>

The ID for Child is currently bwe.near/Child##c##, but after this change becomes bwe.near/Child##c##bwe.near/Parent##p

vercel[bot] commented 1 month ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
bos-web-engine ✅ Ready (Inspect) Visit Preview Mar 28, 2024 8:34pm
bos-web-engine-docs ✅ Ready (Inspect) Visit Preview Mar 28, 2024 8:34pm
bos-web-engine-sandbox ✅ Ready (Inspect) Visit Preview Mar 28, 2024 8:34pm