Fork me on GitHub
#react
<
2021-08-24
>
lilactown15:08:05

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

lilactown15:08:20

"useMutableSource and selector stability"

lilactown15:08:58

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

lilactown23:08:16

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

lilactown23:08:46

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

lilactown23:08:38

(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 []]})

❤️ 11