Skip to content

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

@lcoder

Description

@lcoder

最后的一部分内容:

例如,对于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吗?这里不是很理解,感谢解答

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions