Tags: dmjio/miso
Tags
Initial commit of typesafe `React` props. (#1518) * Initial commit of typesafe `React` props. [Props](https://react.dev/learn/passing-props-to-a-component) are used in React to provide parent-to-child communication. This PR extends the `Component` and `View` classes, parameterizing them by both `props` and `parentAction`. `parentAction` allows a child `Component` to write to the `parent` `Sink`. This is useful when using the `props` feature to make use of the parent's `update` function from the `child` `Component`. This is a common pattern in React. The `withParentSink` function has been introduced to facilitate this. - [x] Adds `mountProps_`, `mountProps` combinators for storing 'props' on a 'VComp'. - [x] `Component`, `ComponentState` are now parameterized by `props`. - [x] `view` has been extended to receive a `Maybe props` argument. - [x] `parentAction` now parameterizes both `Component` and `Effect`. N.B. if `props` are `Nothing`, the diffing function will not diff props. The callback will not be invoked. Practically, this change ensures that "props" are propagated throughout a `Component` subtree, to all descendants, invoking the render phase only (bypassing the commit phase). * Drop `withParent` and `parentAction`. Adjust comment on `mountProps_` * `Maybe props` -> `props`, docs. Use `globalProps`. Pass in `initialProps` as `()`. * Clean up commented code in Effect.hs Removed commented-out code for someAction in Effect.hs. * Drop unneeded `liftIO`, guard `_componentDraw`. * Batch negated `ComponentId` during `dequeue`. * Refactor comments in Effect.hs for Lens functions Updated comments for clarity and consistency in Lens definitions. * `mountProps` -> `mountWithProps` * Replace `globalProps` w/ `_componentProps`
PreviousNext