Skip to content

feat: implement React Hooks library for Live Context State Management (#37)#58

Open
annukumar123 wants to merge 2 commits into
Memact:mainfrom
annukumar123:feat/issue-37-react-hooks
Open

feat: implement React Hooks library for Live Context State Management (#37)#58
annukumar123 wants to merge 2 commits into
Memact:mainfrom
annukumar123:feat/issue-37-react-hooks

Conversation

@annukumar123

Copy link
Copy Markdown

🔎 Overview

This PR introduces an agnostic React Hooks state library mapping to issue #37, exposing clean context abstractions for application components subscribing to live streaming token updates.

🛠️ Changes Implemented

  • React Component Interface: Created src/react.mjs exporting a functional MemactProvider element and custom useContextClaim() live state observer hooks.
  • Architecture Adaptation: Built with safe fallback duck-typing bindings to prevent runtime failures in pure non-browser/vanilla execution steps.
  • Workspace Exports: Exposed primitives directly from the main bundle entry map inside src/index.mjs.
  • decoupled Testing: Added robust isolated environment coverage vectors inside test/react.test.mjs running completely clean with 0 external dependencies.

Fixes #37

@keepsloading keepsloading added Hard Hard difficulty issue SSoC26 labels Jul 8, 2026

@keepsloading keepsloading left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@annukumar123 Thanks for working on this! I've reviewed the PR and have a few requests for changes:

  1. ReactInstance check uses window.React, which can throw a ReferenceError in non-browser environments if window is completely undefined. You should check typeof window !== "undefined" which you did, but then it's safer to use globalThis.React.
  2. The MemactProvider implementation dynamically tries to create a Context on every render: R.createElement(R.createContext(null).Provider, ...). createContext should be called OUTSIDE of the component rendering cycle. If it's called inside, it creates a new context instance on every render, and consumers will never re-render when the value changes, or they won't be able to match the context instance. You should export a stable context instance.
  3. In useContextClaim, contextClient is currently being extracted as typeof options.client === "object" ? options.client : null. This defeats the purpose of the MemactProvider! The hook should use React.useContext with the stable context instance created outside the component to get the client provided by MemactProvider.

Please address these architectural issues with the React bindings and push the changes. Thank you!

@annukumar123

Copy link
Copy Markdown
Author

@keepsloading
I have the make the necessary changes. you can verify now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hard Hard difficulty issue SSoC26

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SSoC26] [Easy] React Hooks library for Live Context State Management

2 participants