Skip to content

in Core.js - UNSAFE_willMount removed & put defaultSort to url #19

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion __tests__/SortFilter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ test('Instantiate SortFilter component via mount', () => {
expect(wrapper.find(Core).instance().element.current).toMatchSnapshot();
})

function Elements({ itemSelector }) {
function Elements({ itemSelector, records }) {
return records.map((record) => <Element key={record.id} record={record} itemSelector={itemSelector} />);
}

Expand Down
29 changes: 2 additions & 27 deletions src/SortFilter/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,12 @@ class Core extends Component {
super(props);
this.state = {
// taxonomies: {},
taxonomiesBodyTypeNames: []
taxonomiesBodyTypeNames: Object.keys(this.props.taxonomies['Body Types'])
};
this.element = React.createRef();
this.sizer = React.createRef();
}

UNSAFE_componentWillMount() {
/**
* Kick off the network request and update the state once it returns.
*/
const { taxonomies } = this.props;
this._loadProps()
.then(() => {
this.setState({
// taxonomies,
taxonomiesBodyTypeNames: Object.keys(taxonomies['Body Types'])
});
});
}

componentDidMount() {
// let options = {
// // reverse: true,
Expand All @@ -49,6 +35,7 @@ class Core extends Component {
sizer: this.sizer.current,
// initialSort: options
});
putSearchParams(this.props.defaultSort);
this.sortFromUrlSearch();
}

Expand Down Expand Up @@ -144,18 +131,6 @@ class Core extends Component {
this.slider.classList.toggle('slider-closed');
}

/**
* Set delay
* @return {Promise<Object[]>} A promise which resolves with an array of objects.
*/
_loadProps() {
return new Promise((resolve) => {
setTimeout(() => {
resolve(this.props);
}, 500);
});
}

render() {
const { taxonomiesBodyTypeNames } = this.state;
const { children, itemSelector } = this.props;
Expand Down