Props not ready in komposer container?


#1

my props.id doesn’t seem too be ready when the container is initially loading up-- and so it throws an error in the publication that requires that props.id String…

There’s a few different ways to wait on it, but what is the best practice in this case?

component that is passing props to container:

import Single from 'single-container.js'
//etc.etc.etc.

//props are coming from a layout component that gets them from react-router
export const SinglePage = (props) => (
  <Single id={props.params.id} /> 

);

komposer container

import { composeWithTracker } from 'react-komposer';
import { Messages } from '../../../../api/Messages/Messages.js';
import { Single } from './single.js'; // component being wrapped by this komposer container
import { Loading } from '../../loading.js';
import { Meteor } from 'meteor/meteor';


const composer = (props, onData) => {

  const messagesSub = Meteor.subscribe('messages', props.id);
  
  if (messagesSub.ready()) {
    
    let messages = Messages.find({messageType: 'report', parentId: id}).fetch();

    onData(null, { messages});
  }
};

export default composeWithTracker(composer, Loading)(Single);