Ensure component is mounted before trying to access its refs