How to wait for a subscription to be ready in a React container

I have this container and I would like to be able to wait for the subscription - how can I do this?

export default createContainer(({ params }) => {
    const dataHandle = Meteor.subscribe('lists');
    const dataIsReady = dataHandle.ready();
    return {
        dataIsReady,
        data: dataIsReady ? Lists.find() : []
    };
}, ListTable);
1 Like

in your ListTable component, wrap the component in

if (this.props.dataIsReady) {}
2 Likes

Like this?

render() {
            return (
                if (this.props.dataIsReady) {
                    <div className="table-format-1">
                        <table id="listTable">
                        </table>
                    </div>
                }
            );
        
    }
const renderComponent = this.props.dataIsReady ? (
    <div className="table-format-1">
           <table id="listTable"></table>
     </div>
) : "";

render() {
    return {renderComponent}
}
1 Like