Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

书本第180页,TodoList链接到了store,但是TodoItem并没有,mapStateToProps为null,不是很理解 #109

Open
lcoder opened this issue Dec 17, 2018 · 0 comments

Comments

@lcoder
Copy link

lcoder commented Dec 17, 2018

最后的一部分内容:

例如,对于TodoItem组件的单元测试,就可以在JSX中直接这样写,不用Provider:

const subject = <TodoItem store={ store }  { ...otherProps } />
const wrapper = mount( subject )

todoItem第47行代码
看了TodoItem的代码,里面没用到store,书中说这样写是为了:如果被测试的组件并不包含任何其他链接到store的子组件,那就可以直接在组件渲染中用名为store的prop。可被测试的组件如果压根没用到store,那这样子写是为了什么?是connect之后的被链接的组件会取this.props.store吗?这里不是很理解,感谢解答

@lcoder lcoder changed the title 书本第180页,TODOList 书本第180页,TodoList链接到了store,但是TodoItem并没有吧,mapStateToProps为null,不是很理解 Dec 17, 2018
@lcoder lcoder changed the title 书本第180页,TodoList链接到了store,但是TodoItem并没有吧,mapStateToProps为null,不是很理解 书本第180页,TodoList链接到了store,但是TodoItem并没有,mapStateToProps为null,不是很理解 Dec 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant