Skip to content

Commit

Permalink
Web container override (#691)
Browse files Browse the repository at this point in the history
* PLV now render after first onLayout

* ..

* scrollable node now a public API

* missed override implementation for web

* version bump

Co-authored-by: Talha Naqvi <talha.naqvi@shopify.com>
  • Loading branch information
naqvitalha and naqvitalha authored Mar 8, 2022
1 parent 2ed1bee commit 9772387
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "recyclerlistview",
"version": "3.1.0-beta.4",
"version": "3.1.0-beta.5",
"description": "The listview that you need and deserve. It was built for performance, uses cell recycling to achieve smooth scrolling.",
"main": "dist/reactnative/index.js",
"types": "dist/reactnative/index.d.ts",
Expand Down
20 changes: 12 additions & 8 deletions src/platform/web/viewrenderer/ViewRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ export default class ViewRenderer extends BaseViewRenderer<any> {
private _dim: Dimension = { width: 0, height: 0 };
private _mainDiv: HTMLDivElement | null = null;
public componentDidMount(): void {
if (super.componentDidMount) {
super.componentDidMount();
}
super.componentDidMount();
this._checkSizeChange();
}

Expand All @@ -42,19 +40,25 @@ export default class ViewRenderer extends BaseViewRenderer<any> {
...this.props.styleOverrides,
...this.animatorStyleOverrides,
};
return (
<div ref={this._setRef} style={style}>
{this.renderChild()}
</div>
);
const props = {
style,
ref: this._setRef,
};
return this._renderItemContainer(props, this.props, this.renderChild()) as JSX.Element;
}

protected getRef(): object | null {
return this._mainDiv;
}

private _renderItemContainer(props: object, parentProps: ViewRendererProps<any>, children: React.ReactNode): React.ReactNode {
return (this.props.renderItemContainer && this.props.renderItemContainer(props, parentProps, children)) || (<div {...props}>{children}</div>);
}

private _setRef = (div: HTMLDivElement | null): void => {
this._mainDiv = div;
}

private _getTransform(): string {
return "translate(" + this.props.x + "px," + this.props.y + "px)";
}
Expand Down

0 comments on commit 9772387

Please sign in to comment.