react

lilactown 2021-08-24T15:59:05.025400Z

this is a great discussion for library authors: https://github.com/reactwg/react-18/discussions/84

lilactown 2021-08-24T15:59:20.025600Z

"useMutableSource and selector stability"

lilactown 2021-08-24T15:59:58.026300Z

seems v relevant for people maintaining or building libraries for managing state external from React

lilactown 2021-08-24T23:54:16.026600Z

I'm working on a library for interacting with React from a REPL

lilactown 2021-08-24T23:54:46.027200Z

currently you can look up an instance of a component on the page (called a fiber) and get things like props, state, and children

lilactown 2021-08-24T23:58:38.030900Z

(require '[react-repl.core :as rr])

(rr/find my-component)
;; => #object[FiberNode]

(-> (rr/find my-component)
    (rr/state))
;; => ({:type "useState", :current {:name "foo"}, :dispatch #object[dispatch]} {:type "useCallback" :current #js [object[Function] #js []]})

(-> (rr/find my-component)
    (rr/props))
;; => {:initial-name "foo"}

(-> (rr/find my-component)
    (rr/state)
    (first)
    (rr/hook-dispatch {:name "bar"}))
;; => {:name "bar"}

(-> (rr/find my-component)
    (rr/state))
;; => ({:type "useState", :current {:name "bar"}, :dispatch #object[dispatch]} {:type "useCallback" :current #js [object[Function] #js []]})

❤️ 2