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

Data Module: Expose state using discoverable selectors #4421

Closed
wants to merge 4 commits into from

Conversation

atimmer
Copy link
Member

@atimmer atimmer commented Jan 12, 2018

This continues the work of #4105 by making selectors discoverable. All selectors are available on the wp.data.selectors object. The data module handles passing the state to the selectors. So a consumer of wp.data.selectors can use these functions without knowing about the state.

Using the HoC looks like this:

const MyComponentWithData = query( ( selectors ) => {
	return {
		title: selectors[ 'core/editor' ].getEditedPostTitle(),
	};
} )( props =>
  <div>{ props.title || 'no title' }</div>
);

cc @youknowriad, @gziolo, @mcsf, @moorscode

Closes #4105
Closes #4083
Closes #2473

youknowriad and others added 4 commits December 20, 2017 11:14
All selectors are available on wp.data.selectors. Inside the HoC you
get passed the object, so you can just do:

```js
( selectors ) => {
	return title: selectors[ "core/editor" ].getEditedPostTitle();
}
```
@atimmer
Copy link
Member Author

atimmer commented Jan 17, 2018

Superseded by #4105

@atimmer atimmer closed this Jan 17, 2018
@gziolo gziolo deleted the add/discoverable-selectors-api branch January 17, 2018 11:57
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

Successfully merging this pull request may close these issues.

2 participants