-
Notifications
You must be signed in to change notification settings - Fork 5
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
Upgrade React_View to support ES6 classes, and the newest React.js #20
Comments
We already have a ES5 version of what you're proposing. It used to be called So I think we could rename this bug report to "Upgrade Here's an example of using React_View: <script src="https://stateb.us/client4.js"></script>
<script>
var comp = React_View({
displayName: 'My Component',
render: function () {
var foo = fetch('/foo')
return React.DOM.div({
style: {
color: this.props.color,
height: foo.height,
width: foo.width,
}
}
})
document.addEventListener('DOMContentLoaded', function () {React.render(comp(), document.body)}, false)
</script> React components used to be raw We should add React_View to the readme. And we might also want to reconsider the name, I haven't thought about the best name for this function yet. It used to be called ReactiveComponent, just like you called it above. You can see the name ReactiveComponent being used in the current consider.it code. We used this system for all of consider.it. |
I haven't learned es6 modules yet. Do they actually eliminate |
Yeah :/ But that still seems cleaner than adding script tags in the correct order. |
Ok, cool, I agree with you. We can also write our own Plus, once we have this basic system working, we can add sweet new features:
So I think the future of statebus code loading will be about code living on statebus itself, and live updating the code affecting all servers and clients that fetch it. If we implement the basic version of that now, we can address your dislike for <script> tags with their crappy dependency resolution and global variables, and be ready to add the sweet extended features in the future whenever we want to, which will upgrade all statebus sites using this API without them having to change anything. I'm sending you some links now (in your fb messages) on the discussions we've had for this feature. |
For the record I'll use statebus version because setting up webpack doesn't sound very fun. |
This is almost done. I think I'm going to change the API name too, so and write up docs for it, and make it connect easily to HTTP servers, so that people can easily use statebus to connect react components to existing REST servers. |
Big drawback: This is obviously more verbose than the coffeescript client:
But the ES6 version has some benefits:
There's a lot less magic -- no "dom.PROPERTY", no weird runtime compilation errors, it's obvious where "this.props" comes from, etc.
We can use import/export to easily use/write libraries. I'm not a huge fan of including
<script>
tags and using global variables.I personally like OOP. Sharing (private) state between all of the react state hooks can happen through properties on the object, rather than statebus.
People familiar with React will find the ES6 version familiar.
The text was updated successfully, but these errors were encountered: