Skip to content

Commit 008375c

Browse files
committed
Use const when we can.
1 parent 320a4bc commit 008375c

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

lib/Resizable.jsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export default class Resizable extends React.Component {
8787

8888
// If you do this, be careful of constraints
8989
runConstraints(width: number, height: number): [number, number] {
90-
let [min, max] = [this.props.minConstraints, this.props.maxConstraints];
90+
const [min, max] = [this.props.minConstraints, this.props.maxConstraints];
9191

9292
if (this.props.lockAspectRatio) {
9393
const ratio = this.state.width / this.state.height;
@@ -97,7 +97,7 @@ export default class Resizable extends React.Component {
9797

9898
if (!min && !max) return [width, height];
9999

100-
let [oldW, oldH] = [width, height];
100+
const [oldW, oldH] = [width, height];
101101

102102
// Add slack to the values used to calculate bound position. This will ensure that if
103103
// we start removing slack, the element won't react to it right away until it's been
@@ -133,16 +133,17 @@ export default class Resizable extends React.Component {
133133
*/
134134
resizeHandler(handlerName: string): Function {
135135
return (e, {node, deltaX, deltaY}: DragCallbackData) => {
136-
let width = this.state.width + deltaX, height = this.state.height + deltaY;
136+
let width = this.state.width + deltaX;
137+
let height = this.state.height + deltaY;
137138

138139
// Early return if no change
139-
let widthChanged = width !== this.state.width, heightChanged = height !== this.state.height;
140+
const widthChanged = width !== this.state.width, heightChanged = height !== this.state.height;
140141
if (handlerName === 'onResize' && !widthChanged && !heightChanged) return;
141142

142143
[width, height] = this.runConstraints(width, height);
143144

144145
// Set the appropriate state for this handler.
145-
let newState = {};
146+
const newState = {};
146147
if (handlerName === 'onResizeStart') {
147148
newState.resizing = true;
148149
} else if (handlerName === 'onResizeStop') {

lib/ResizableBox.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default class ResizableBox extends React.Component {
2323
};
2424

2525
onResize = (event, {element, size}) => {
26-
let {width, height} = size;
26+
const {width, height} = size;
2727

2828
this.setState(size, () => {
2929
this.props.onResize && this.props.onResize(event, {element, size});
@@ -35,7 +35,7 @@ export default class ResizableBox extends React.Component {
3535
// Basic wrapper around a Resizable instance.
3636
// If you use Resizable directly, you are responsible for updating the child component
3737
// with a new width and height.
38-
let {handleSize, onResizeStart, onResizeStop, draggableOpts,
38+
const {handleSize, onResizeStart, onResizeStop, draggableOpts,
3939
minConstraints, maxConstraints, lockAspectRatio, width, height, ...props} = this.props;
4040
return (
4141
<Resizable

0 commit comments

Comments
 (0)