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

Refactor componentWillReceiveProps #1253

Open
wants to merge 3 commits 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
10 changes: 6 additions & 4 deletions showcase/examples/force-directed-graph/force-directed-graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,12 @@ class ForceDirectedGraph extends React.Component {
};
}

componentWillReceiveProps(nextProps) {
this.setState({
data: generateSimulation(nextProps)
});
componentDidUpdate(prevProps, prevState, snapshot) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why snapshot parameter is declared if it's not used inside componentDidUpdate. Remove unused parameters.

if (this.props !== prevProps) {
this.setState({
data: generateSimulation(this.props)
});
}
}

render() {
Expand Down
19 changes: 10 additions & 9 deletions showcase/examples/responsive-vis/responsive-scatterplot.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,16 @@ export default class ResponsiveScatterplot extends React.Component {
selectedPoints: []
};

componentWillReceiveProps(nextProps) {
// not the greatest
this.setState({
binData: transformToBinData(
nextProps.data,
nextProps.width,
nextProps.height
)
});
componentDidUpdate(prevProps, prevState, snapshot) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unused parameters.

if (this.props !== prevProps) {
this.setState({
binData: transformToBinData(
this.props.data,
this.props.width,
this.props.height
)
});
}
}

getFeatures() {
Expand Down
Loading