react-transmit icon indicating copy to clipboard operation
react-transmit copied to clipboard

Initial Variables required unnecesarily

Open sebasgarcep opened this issue 9 years ago • 3 comments

First of all, nice project! I want to point out an issue I found recently. I tried implementing this in one of my projects but the Container wouldn't render so I ended up tracing the error to the componentWillMount lifecycle method of the Container, specifically to this line: https://github.com/RickWong/react-transmit/blob/master/src/lib/createContainer.js#L239. Going down that function call I noticed that this function returns false if the isRootContainer property of the Container is false, which in my case was because I hadn't declared initialVariables (https://github.com/RickWong/react-transmit/blob/master/src/lib/createContainer.js#L30). Once I set initialVariables to {} it worked as expected, but in my humble opinion that should have been uneccesary as I don't use any variables in my fragment functions. Or is this behaviour intended?

EDIT: Even if this behaviour is intended I don't think it should fail silently.

sebasgarcep avatar Feb 12 '16 17:02 sebasgarcep

I'll just quote from closed issue #49 where @RickWong said:

I really need to document this somewhere. Containers with initialVariables are so-called "root containers" and their fragments are fetched at start. Containers without initialVariables will never be automatically fetched. It's by design.

mauriciopasquier avatar Feb 17 '16 05:02 mauriciopasquier

It's really a lack of API design. I know. You guys have any suggestions to make it better?

RickWong avatar Feb 18 '16 00:02 RickWong

Console warnings (though I've been reading they aren't portable) and something in the docs might be useful. I won't be available for a couple of days so that is as much help as I can give.

sebasgarcep avatar Feb 18 '16 06:02 sebasgarcep