React & Jest, how to test changing state and checking for another component

后端 未结 2 472
孤街浪徒
孤街浪徒 2020-12-08 20:07

React - Test Utilities Docs

I have a Login component which will display a Notification component if this.state.error i

2条回答
  •  情话喂你
    2020-12-08 21:00

    This should probably be refactored a bit. The Notification component should probably be always rendered in a more global component (like a Page Wrapper or some sort of other container), and it should probably render null unless there's errors within a global reducer. A Login component probably shouldn't maintain the responsibility and business logic regarding notifications.

提交回复
热议问题