futursolo / stylist-rs

A CSS-in-Rust styling solution for WebAssembly Applications
https://crates.io/crates/stylist
MIT License
373 stars 22 forks source link

`styled_component_base` as lower level primitive of `styled_component` #52

Closed WorldSEnder closed 3 years ago

WorldSEnder commented 3 years ago

Maybe impl_styled_component is a better name than styled_component_base for this macro?

I was also debating use_stylist as I think the angle of using it in custom hooks is a valid and useful use case. The use_style! macro as is invokes use_context once per usage, while the injected css! macro reuses the same manager, retrieved only once. Quite unsure if there's any strong conclusions to draw from this.

futursolo commented 3 years ago

use_style! macro as is invokes use_context once per usage

I think there's very little incentive to optimise this.

I do not think a component would have many use_style! hooks in the same component to the extent that the performance would be degraded.

It is common to access the same context with useContext multiple times in custom hooks in React. Accessing context content should be a cheap operation, or else it's a problem of Yew to optimise.

https://github.com/reduxjs/react-redux/blob/master/src/hooks/useSelector.ts#L143