Meteor-Community-Packages / Meteor-CollectionFS

Reactive file manager for Meteor
MIT License
1.05k stars 237 forks source link

Error when doing SSR. path: / Object [object Object] has no method 'url' #835

Open zachariahtimothy opened 8 years ago

zachariahtimothy commented 8 years ago

Not sure this is a CollectionFS bug, React, or Flow Router issue but I have found on the server side rendering of React components CollectionFS media does not have a method .url(). The media returns just fine with all the copies one would expect but the url function is undefined. This works fine on the client side. I am using Meteor, React, FlowRouterSSR, and ReactLayout. If I run the following in the JSX file (outside of the React component) it works fine:

    Meteor.startup(function () {
        Meteor.setTimeout(function () {
            var media = Collections.Media.findOne();
            console.log('media url', media.url);
        }, 1)
    });

Putting the query and console.log ANYWHERE in the React component and the media is found, but .url is undefined. Again I know this may not be a CollectionFS bug but I am at a loss why .url works fine everywhere else, but not within React componenets. Thanks!

bmustata commented 8 years ago

+1

zachariahtimothy commented 8 years ago

@bmustata not sure if you saw it but I created a Gist to show how I got this working. Not sure it is the sexiest code but it works consistently. https://gist.github.com/zachariahtimothy/4e150b3931e4f299138e