-
Notifications
You must be signed in to change notification settings - Fork 87
Check all exports for being React components #26
Comments
Oh man, I have no idea how to do this that isn't going to cause a mess of other problems. |
What kind of problems? This is exactly how React Hot Loader currently works, and it's pretty stable. |
You'll have to explain how it works, I would check the tests in the react-hot-loader repo but you don't have any... :for_shame: |
@thejameskyle it's just a development tool dude, not for production |
I understand that dude, development tools need tests too. |
Actually that's exactly why this project was started. It was easier to split RHL into several different projects than to write tests for it :-) RHL just enumerated every key in let wrappedComponents = [];
wrapExport(something) {
if (
something &&
something.prototype &&
something.prototype.isReactComponent && // only finds Component descendants but good enough
wrappedComponents.indexOf(something) === -1 // don't wrap twice
) {
wrappedComponent.push(something); // normal generated code would also need to do that
return wrapJustLikeWeWrapInGeneratedCode(something);
}
return something; // not an export we should hijack
} Then every This is a runtime check but it's important for many cases where we want export a React class generated by some factory in another file, and it's essential to maintain its identity. |
+1 Would like to see this. I am actually working on a backbone/react application and using the |
Interesting, can you show code that fails? In s separate issue. |
@gaearon will do. |
This is fixed in React Hot Loader 3. I’m closing the issue as unsolvable in this repo. |
Currently exports are not being checked. This is, in a way, a regression from React Hot Loader which used to check every export for componentish-ness. It's hitting us really bad in some cases:
Explore wrapping HOCs at the call site #18 could potentially fix this, but I have no idea how to even get started on it without a dependency graph, so in the meantime, we should implement exactly what React Hot Loader did: check every export for being a component.
The text was updated successfully, but these errors were encountered: