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

Create an element from a ComponentClass #9

Closed
wants to merge 3 commits into from

Conversation

ethul
Copy link
Contributor

@ethul ethul commented Jan 29, 2015

An example use-case for this function is when a component class is imported and it is desired to render an instance of this class within another component or as the top-level component.

For instance, rackt/react-router exports Route, DefaultRoute, RouteHandler, etc. The createElementFromClass function can be used to render these exported classes.

As a note, I am still pretty new at React, so perhaps there is a better way to do this. Or maybe there is already a way to achieve what I want here. I am open to ideas or alternatives.

An example use-case for this function is when a component class is
imported and it is desired to render an instance of this class within
another component or as the top-level component.

For instance, rackt/react-router exports Route, DefaultRoute,
RouteHandler, etc. The createElementFromClass function can be used to
render these exported classes.
@paf31
Copy link
Owner

paf31 commented Jan 29, 2015

This looks good. However, I put together a similar PR recently. My question is how we should handle props correctly. If I create my own component class, its props are part of its type, but using this new function, I can use it with any props. Can you see a way to resolve this without making all of the props untyped?

@ethul
Copy link
Contributor Author

ethul commented Jan 29, 2015

Ah, sorry about that. I totally missed pull request #4. Good point about the props. I will take a second look. Hopefully we can find a good way to do this.

@ethul
Copy link
Contributor Author

ethul commented Feb 18, 2015

I've been thinking about how to resolve this issue, and I admit that I still don't have an approach in mind yet for thermite.

However, I have been exploring a free monad based abstraction for react, purescript-reactf, which keeps the type of the props with a component, whether it is created by the user or imported as a foreign import.

The purescript-reactf module is still rather experimental and was originally intended to hash out some ideas, but I thought it might be useful for discussion, if nothing else. I'd be curious if you had any comments, suggestions, or feedback.

@paf31
Copy link
Owner

paf31 commented Feb 18, 2015

I think it looks really nice :) I need to spend a bit more time to fully understand it, but I like it.

@ethul
Copy link
Contributor Author

ethul commented Feb 18, 2015

Thanks! And I am definitely open to any suggestions or ideas that you or others might have.

@paf31 paf31 closed this May 17, 2015
@paf31
Copy link
Owner

paf31 commented May 17, 2015

This has been implemented in 0.7.0.

@ethul
Copy link
Contributor Author

ethul commented May 17, 2015

Looks good. Thanks!

On Sunday, May 17, 2015, Phil Freeman notifications@github.com wrote:

This has been implemented in 0.7.0.


Reply to this email directly or view it on GitHub
#9 (comment)
.

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

Successfully merging this pull request may close these issues.

None yet

2 participants