Comments (15)
What specific tool is checking for that? I would think this is poor practice in general.
from stamp-specification.
It's react-redux-provide. However my first issue was about propTypes
not being on a stamp (aka class), but that was only my mistake and those were there actually. That check for render
doesn't seem to be actually that much relevant.
General question here is if stamps should be compatible with classes in how they look like to outside world. I assume it will be some time before stamps can actually replace classes.
from stamp-specification.
I am not really sure that it should be statics that go to prototype
. Why? Even mentioned render
method is not static one, it's instance method.
from stamp-specification.
@FredyC My late evening mind tricked me. Thank you for clarification. I've updated the issue. Now, it's says "methods" instead of "statics". Sorry about that.
from stamp-specification.
Explicitly checking the prototype for something is bad practice IMO. Instead of seeing if the instance has the method, it's looking for the object to have a specific structure and the method.
Also, checking the instance for a top-level method will check the prototype chain.
Vote for 2
from stamp-specification.
This is not about instance checking @JosephClay
This is about constructor structure check.
> function F(){}
> F.prototype.render = function render(){};
> console.log(F.render);
undefined
You are probably confusing instance.__proto__
with a special ConstructorFunction.protoype
object.
So, those tools I mentioned are checking Constructor.prototype
but not instance.__proto__
from stamp-specification.
Yeah, it might not work with react HOC's for example.
@FredyC can you remind which tool you stumbled upon?
from stamp-specification.
I don't think it will be possible to make them 'look' like classes. They are not classes. I think a user would need to make some sort of adapter implementation for those cases. Trying to get close to looking like and behaving like a class based on our assumptions of usage is probably not going to be helpful for those cases anyway.
I think this type of thing will add to the complexity and confusion of learning and understanding stamps in general.
from stamp-specification.
Yea, it's not really a pressing matter right now, this was only single case I've run into and so far doesn't seem relevant. Let's keep it open here in case we find some other reason for this.
from stamp-specification.
If you assigned methods to stamp.prototype
by identity, it would enable instanceof
checks, which IMO, is a bad thing.
from stamp-specification.
I don't think that works like that simply because stamp doesn't have a constructor
property which is used for instanceOf
check.
from stamp-specification.
The constructor
property is not involved at all in the instanceof
check. See my answer to Confused about javascript prototypal inheritance.
Verify for yourself:
function foo() {}
var bar = { a: 'a'};
foo.prototype = bar; // Object {a: 'a'}
baz = Object.create(bar);
baz instanceof foo // true
Note: No constructor
property anywhere...
from stamp-specification.
The constructor property is a developer convention added for convenience.
from stamp-specification.
Ok I did not know about that, thanks.
Either way, let's keep it open here for now. Since this came from a react-stamp, it's more likely end up there and perhaps with just making copy of a render
method on a prototype to fulfill basic needs to identify components.
from stamp-specification.
Bad idea. :) No outcome. Closing the issue.
from stamp-specification.
Related Issues (20)
- Specify details on how are things deeply merged HOT 7
- Allow metadata (descriptors) merging override HOT 6
- Code review of stamp based project HOT 7
- Out of sync docs HOT 4
- The "composers" proposal HOT 38
- Use `Symbol.hasInstance` to fix `instanceOf` operator HOT 5
- Proposal: rename or alias `compose()` to `blend()` HOT 4
- Typo on compose.js comments
- Looking for resources on Stamp HOT 3
- Proposal: await for an initalizer if it is async HOT 7
- Proposal: new metadata "name" to set stamp's `.name` HOT 2
- when i use compose.js, i got a module error. HOT 2
- when use compose, got 'xx.xx is not a function' HOT 4
- getter/setter cannot run HOT 3
- [RFC] Getters and Setters should be copied across with other metadata HOT 2
- The `configuration` vs `deepConfiguration` HOT 3
- Should options default to empty object? HOT 3
- Find a less bulky alternative to mergeWith HOT 3
- Use smaller assign instead of lodash.assign HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stamp-specification.