←back to thread

367 points lemonberry | 1 comments | | HN request time: 0.421s | source
Show context
sam_goody ◴[] No.24642768[source]
If there was a way to write JS within the component, I think that they could have taken off - just see how well components are in React, Vue et al.

And to get that to happen, all you would need is the ability to refer to `this` within the component. Aside for that, treat the JS within the component as a module, ability to access global vars, but within scope.

But instead, you are expected to put the relevant JS in the code that creates the component (in the parent document), which means that reusability and is a pipe dream, and components are really not componentized.

replies(2): >>24646817 #>>24647958 #
1. claytongulick ◴[] No.24647958[source]
I'm not sure what you mean?

All my components are totally encapsulated, and each module is self registering.

All I have to do is import "path/some-component.js" and I can then use <some-component> in any markup I want.