near / react-on-chain

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

feat: couple refs to outer application DOM elements #409

Closed andy-haynes closed 1 month ago

andy-haynes commented 1 month ago

This PR adds support for invoking DOM methods on outer application elements, supporting useRef cases such as:

import { useEffect, useRef } from 'react';

export default function() {
  const input = useRef(null);
  useEffect(() => {
    input.current.focus();
  }, []);

  return <input ref={input} type="text" />;
}

When refs are found on rendered Components (starting with the initial render), they are replaced with proxy objects that post messages to the outer application to invoke the DOM method on that node's corresponding outer application DOM element.

vercel[bot] commented 1 month ago

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

Name Status Preview Comments Updated (UTC)
bos-web-engine ❌ Failed (Inspect) Apr 12, 2024 6:38pm
bos-web-engine-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 12, 2024 6:38pm
bos-web-engine-sandbox ❌ Failed (Inspect) Apr 12, 2024 6:38pm
andy-haynes commented 1 month ago

Failing tests/deployments are because I merged an unrelated issue fix with #410 to unblock the last commit