Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

may need a companion to pureComponent to push a given child to stack #10

Open
leiyangyou opened this issue Jan 12, 2017 · 2 comments
Open

Comments

@leiyangyou
Copy link

ran into a usecase where I need to wrap a component before pushing the component onto the stack

@leiyangyou
Copy link
Author

leiyangyou commented Jan 12, 2017

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.

@leiyangyou leiyangyou reopened this Jan 12, 2017
@hurrymaplelad
Copy link
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants