-
Notifications
You must be signed in to change notification settings - Fork 87
Support pure components #17
Comments
Would love to help tackle this issue here and in |
I just pushed |
Why is the expected output of the pure test with the Arrow Expressions
Is that the correct behavior versus something like:
With
|
You're right about A = _wrapComponent('_$A')(A) right afterwards. But whatever else that does the job will work—as long as it keeps semantics and binding name. |
Oh, sorry, I see what you mean now. This is some outdated version of the test so please disregard this part of it. I seem to not have finished the test :-( |
No problem! Was just checking. For the expected output then, would it make sense for it to be
or does this pattern change because it's an Arrow Function? I'll update the
|
Have a rough initial pass at this that passes an updated test here: joshblack@0f9a777. Had to figure out an alternative to the existing pattern for a Function Declaration (
|
Hi guys, I got the time to look into this, but it is a lot for me to get my head around. Is this repo the only part of the solution? I have seen references to react-proxy and creating a new transformer to support this? Is that the case, or will it work if this plugin is able to identify the functions? I tried your fix @joshblack. Using: function App() {
return (
<div>happ</div>
);
}
export default App; But it does not actually do the rerender on changes. It also failed with: export default function App() {
return (
<div>happ</div>
);
} But thanks for the discussion here, it helped me getting a sense of the challenge :-) I would like to take a crack at it, but yeah, I just have to know if this is where to fix it |
Would also be nice to have some pointers to what actually does the rerendering of the component. As I understand most of the code is related to identifying and replacing syntax? Where does it actually make the component render itself again? :-) |
My understanding is that the point of this project is to codemod application code and provide a wrapper around all supported components. This wrapper is where |
Aha, I see now. So in theory your fix probably works? It is just |
If you'd like to try, I pushed |
Hm, it did not seem to work. But I am hacking this together, so might have done something wrong. Any pro tips on setting up an environment where all of this can be tested at the same time? :-) |
Maybe it doesn't. ;-) You can check whether |
Just to make it clear—even with this change, it won't work if the top-level component is pure. AFAIK there's no easy way we can make it work for top-level component if it is pure. |
Ah, I see, that might have been it. Let me do a new check ASAP. It has been difficult helping out with this. I need to learn by changing the code and see the end result... its just how I learn, hehe. Not quite sure how to set up all the dependencies in a way that lets me change each part and see the end result :-) But I am happy to verify code, so I will get back to you! |
You can install
Any time you change either of their code, you can run |
That said I already discovered a problem with that commit so maybe you can test later. :-) |
Hehe, cool! Let me know @gaearon :-) |
Superseded by #34. |
We should extend the transform to find and wrap pure components.
I think a good enough heuristic for us is to catch functions that contain JSX.
We should also support them in react-proxy: gaearon/react-proxy#12
The text was updated successfully, but these errors were encountered: