-
-
Notifications
You must be signed in to change notification settings - Fork 222
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
fix(index.tsx): make width and height properties optional in Size int… #797
Conversation
src/index.tsx
Outdated
@@ -880,7 +874,7 @@ export class Resizable extends React.PureComponent<ResizableProps, State> { | |||
} | |||
|
|||
updateSize(size: Size) { | |||
this.setState({ width: size.width, height: size.height }); | |||
this.setState({ width: size.width || 'auto', height: size.height || 'auto' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please use ??
instead of ||
this.setState({ width: size.width || 'auto', height: size.height || 'auto' }); | |
this.setState({ width: size.width ?? 'auto', height: size.height ?? 'auto' }); |
src/index.tsx
Outdated
@@ -870,7 +864,7 @@ export class Resizable extends React.PureComponent<ResizableProps, State> { | |||
this.props.onResizeStop(event, direction, this.resizable, delta); | |||
} | |||
if (this.props.size) { | |||
this.setState(this.props.size); | |||
this.setState({ width: this.props.size.width || 'auto', height: this.props.size.height || 'auto' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.setState({ width: this.props.size.width || 'auto', height: this.props.size.height || 'auto' }); | |
this.setState({ width: this.props.size.width ?? 'auto', height: this.props.size.height ?? 'auto' }); |
src/index.tsx
Outdated
width: this.propsSize?.width ? this.propsSize && this.propsSize.width : 'auto', | ||
height: this.propsSize?.height ? this.propsSize && this.propsSize.height : 'auto', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
width: this.propsSize?.width ? this.propsSize && this.propsSize.width : 'auto', | |
height: this.propsSize?.height ? this.propsSize && this.propsSize.height : 'auto', | |
width: this.propsSize?.width ?? 'auto', | |
height: this.propsSize?.height ?? 'auto', |
@yushaku Thanks for your PR.Sorry for late. Could you please update README.md too? |
…erface to allow for undefined values
@bokuweb I updated it as you mentioned. |
Proposed solution
currently Resizable get props defaultSize with width and height and must enter value for both of them
In update: make width and height properties optional in Size interface to allow for undefined values and it allow user set value for one of them
when i read and update the code, i realize that i can set "auto" for width and height, but i did not got it in any docs then, i think this make lib more flex to use