Open leiyangyou opened 7 years ago
Let me reopen this, and elaborate a bit on the usecase.
The scenario I have is this, when using react-dnd, I need to sometimes wrap a child inside a decorator.
For example connectDragSource, this is what I have to do with just crel and pureComponent
T.crel ->
connectDragSource(do T.pureComponent ->
T.div
T.div
)
Not too bad, what i ended up doing is however this
T.use((teact)->
T.push = (contents)->
teact.stack?.push contents
return contents
T.build = (contents)->
previous = teact.resetStack null
children = contents.apply teact, arguments
teact.resetStack previous
children
)
T.push connectDragSource(T.build ->
T.div
T.div
)
and I do believe that these two primitives are worthwhile considering to be included in the lib itself.
Thanks for writing this up @leiyangyou! I can see how those primitives would be useful. I'd wait for a little more demand before expanding the interface. You could publish your code as a separate mixin (similar to https://github.com/goodeggs/teacup-camel-to-kebab) and we'll revisit based on traction?
ran into a usecase where I need to wrap a component before pushing the component onto the stack