If you resign and that company cancels your visa then you have leave the country anyway you can come back anytime as they will give you NOC. It would be better if you get a job offer from a company whose willing to give and send you a new visa before leaving the country.