meteor / react-packages

Meteor packages for a great React developer experience
http://guide.meteor.com/react.html
Other
573 stars 158 forks source link

react-template-helper@0.2.11 not destroying stateless component #290

Closed sebaslh12 closed 3 years ago

sebaslh12 commented 4 years ago

I have this React stateless component:

export default CourseView = () => {
    const coursePermalink = FlowRouter.getParam('permalink');
    const { dataLoading, course } = useTracker(() => {
        const subs = Meteor.subscribe('courseView', coursePermalink);
        const course = Courses.findOne({ permalink: coursePermalink });
        return {
            dataLoading: !subs.ready(),
            course
        }
    }, [coursePermalink]);

    return (
        <div>
            <a href="/">Go Back</a>
            <h1>{course.title}</h1>
        </div>
    );
}

And its being used inside a blaze template using react-template-helper, everything works until I click on the Go back link, the issue is that the component doesn't get destroyed and it throws an error saying that course is undefined (and it is because the permalink no longer exists). I've tried adding the unmount life cycle hook equivalent and it gets executed but it stills reaches the render and the error appears, is there a way of fixing or avoiding this? why is this happening?.

filipenevola commented 3 years ago

Hi @sebaslh12, is this issue still affecting you?

If so, please respond here and then we can proceed finally analyzing it.