State tax filing

May I ask a follow-up question? What if I live in state A and work remotely for a company located in state B, and I occasionally travel to state B for work? For simplicity, let's say for one tax year, I live in state A for half a year and work remotely, and for the other half a year I travel to state B for work. Does this mean that I need to pay income tax for both state A and state B for half year? Thank you!