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

Define callback refs inline to work with latest versions of Next.js / React #819

Merged
merged 1 commit into from
May 26, 2024
Merged
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
19 changes: 12 additions & 7 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -926,12 +926,6 @@ export class Resizable extends React.PureComponent<ResizableProps, State> {
);
}

ref = (c: HTMLElement | null) => {
if (c) {
this.resizable = c;
}
};

render() {
const extendsProps = Object.keys(this.props).reduce((acc, key) => {
if (definedProps.indexOf(key) !== -1) {
Expand Down Expand Up @@ -961,7 +955,18 @@ export class Resizable extends React.PureComponent<ResizableProps, State> {
const Wrapper = this.props.as || 'div';

return (
<Wrapper ref={this.ref} style={style} className={this.props.className} {...extendsProps}>
<Wrapper
style={style}
className={this.props.className}
{...extendsProps}
// `ref` is after `extendsProps` to ensure this one wins over a version
// passed in
ref={(c: HTMLElement | null) => {
if (c) {
this.resizable = c;
}
}}
>
{this.state.isResizing && <div style={this.state.backgroundStyle} />}
{this.props.children}
{this.renderResizer()}
Expand Down
Loading