is it possible to reuse JS components?
Pajn opened this issue · 7 comments
Reusing Javascript components would be great and as this just is a wrapper around ReactJS I would expect it to be possible. However I can't find any documentation or obvious way to do it so I would like to know if it's possible?
If it isn't do you know if it would be a hard thing to implement?
@Pajn it should not be a great problem to reuse javascript components. If you have any experience with using dart:js
library, it should work this way:
import 'dart:js';
import 'package:react/react.dart';
class MyComponent extends Component {
render() => context['customJSComponent'].apply( // calling js function
[ // you need to provide List of arguments
new JsObject.jsify({"some_prop": "some_value"}) // Maps converted to JsObjects
]);
}
It'd be nice if this package provided a way to do this, without having to interact directly with JS interop.
@danschultz totally agree with you! Do you think you could provide some proposal or patch?
@hleumas sure, I'll file a ticket with a proposal for people to review. Do you think that having a high level createElement(String type, Map props, List children)
would be a good api?
@danschultz I am just not sure about the type
argument. This automatically implies the component is in the global namespace. It would be best if you created separate issue for this and describe also how should it work with modules.
@danschultz thanks:)