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
Replace render functions with components #496
Comments
#486) BREAKING CHANGES: The Grid's `rootTemplate`, `headerPlaceholderTemplate`, and `footerPlaceholderTemplate` properties have been replaced with `rootComponent`, `headerPlaceholderComponent`, and `footerPlaceholderComponent`. This also means that they accept components instead of render functions. Find more details here: #496 The `headerTemplate`, `bodyTemplate`, and `footerTemplate` properties have been replaced with the `children` property in `rootTemplate`.
Is there some example how to do this with Any prediction to release date of this breaking changes? |
Hi, |
…leView (#485) BREAKING CHANGES: The TableView's `tableLayoutTemplate`, `tableCellTemplate`, `tableRowTemplate`, `tableNoDataCellTemplate`, `tableNoDataRowTemplate`, `tableStubCellTemplate`, and `tableStubHeaderCellComponent` properties have been replaced with `layoutComponent`, `getCellComponent`, `rowComponent`, `noDataCellComponent`, `noDataRowComponent`, `stubCellComponent` and `stubHeaderCellComponent`. This also means that they accept components instead of render functions. Find more details here: #496
…leSelection (#502) BREAKING CHANGES: The TableSelection plugin's `highlightSelected` property has been renamed to `highlightRow`. The `selectCellTemplate` and `selectAllCellTemplate` properties have been replaced with `cellComponent`, and `headerCellComponent` ones, which accept components instead of render functions. Find more details here: #496 Properties passed to `headerCellComponent` have the same names as arguments passed to the `selectAllCellTemplate` function with the following exceptions: - The `onToggle` property is used instead of the `toggleAll` argument. - The `disabled` property is used instead of the `selectionAvailable` argument and it's value is inverted. Properties passed to `cellComponent` have the same names as arguments passed to the `selectCellTemplate` function except for the `onToggle` property, which is used instead of the `changeSelected` argument.
…leRowDetail (#505) BREAKING CHANGES: The TableRowDetail plugin's `detailToggleCellWidth` property has been renamed to `toggleColumnWidth`. The `template`, `detailCellTemplate`, `detailRowTemplate`, and `detailToggleCellTemplate` properties have been replaced with `contentComponent`, `cellComponent`, `rowComponent`, and `toggleCellComponent` ones, which accept components instead of render functions. Find more details here: #496 Properties passed to `cellComponent` have the same names as arguments passed to the `detailCellTemplate` function except for the `children` property, which is used instead of the `template` argument. Properties passed to `toggleCellComponent` have the same names as arguments passed to the `detailToggleCellTemplate` function except for the `onToggle` property, which is used instead of the `toggleExpanded` argument.
…leHeaderRow (#508) BREAKING CHANGES: The TableHeaderRow's `headerCellTemplate`, and `headerRowTemplate` properties have been replaced with `getCellComponent`, and `rowComponent`, which accept components instead of render functions. Find more details here: #496 Properties passed to `getCellComponent` have the same names as arguments passed to the `headerCellTemplate` function with the following exceptions: the `onSort`, `onGroup`, `onWidthChange` and `onDraftWidthChange` properties are used instead of the `changeSortingDirection`, `groupByColumn`, `changeColumnWidth` and `changeDraftColumnWidth` arguments respectively.
…bleFilterRow (#512) BREAKING CHANGES: The TableFilterRow plugin's `filterCellTemplate` and `filterRowTemplate` properties have been replaced with `getCellComponent`, and `rowComponent` ones, which accept components instead of render functions. Find more details here: #496 Properties passed to `getCellComponent` have the same names as arguments passed to the `filterCellTemplate` function except for the `onFilter` property, which is used instead of the `setFilter` argument.
…leGroupRow (#511) BREAKING CHANGES: The TableGroupRow plugin's `groupIndentColumnWidth` property has been renamed to `indentColumnWidth`. The `groupCellTemplate`, `groupRowTemplate` and `groupIndentCellTemplate` properties have been replaced with `getCellComponent`, `rowComponent`, and `indentCellComponent` ones, which accept components instead of render functions. Find more details here: #496 Properties passed to `getCellComponent` have the same names as arguments passed to the `groupCellTemplate` function with the following exceptions: - The `onToggle` property is used instead of the `toggleGroupExpanded` argument. - The `expanded` property is used instead of the `isExpanded` argument.
…gDropContext (#524) BREAKING CHANGES The DragDropContext plugin's `containerTemplate ` and `columnTemplate ` properties have been replaced with `containerComponent ` and `columnComponent ` ones, which accept components instead of render functions. Find more details here: #496 Properties passed to the `containerComponent` property have the same names as arguments passed to the `containerTemplate` function except for the `children` property which is used instead of the `columns` and `columnTemplate` arguments.
…leColumnReordering (#528) BREAKING CHANGES The TableColumnReordering plugin's `tableContainerTemplate`, `reorderingRowTemplate` and `reorderingCellTemplate` properties have been replaced with `tableContainerComponent` and `rowComponent`, `cellComponent` ones which accept components instead of render functions. Find more details here: #496
…bleEditColumn (#522) BREAKING CHANGES: The TableEditColumn plugin's `commandTemplate`, `cellTemplate` and `headingCellTemplate` properties have been replaced with `getCommandComponent`, `cellComponent`, and `headerCellComponent` ones, which accept components instead of render functions. Find more details here: #496 Properties passed to a component returned from `getCommandComponent` have the same names as arguments passed to the `commandTemplate` function with the following exception. The `onExecute` property is used instead of the `executeCommand` argument. All properties passed to the `cellTemplate` except `row` have been replaced by the `children` property providing configured commands. All properties passed to the `headingCellTemplate` have been replaced by the `children` property providing configured commands.
…upingPanel (#540) BREAKING CHANGES: The GroupingPanel plugin's `groupPanelTemplate`, and `groupPanelItemTemplate` properties have been replaced with `containerComponent`, and `itemComponent` ones, which accept components instead of render functions. Find more details here: #496 `containerComponent` takes on the `children` property instead of all arguments passed to the `groupPanelTemplate` function. The `onSort`, and `onGroup` properties passed to `itemComponent` are used instead of the `changeSortingDirection`, and `groupByColumn` arguments passed to the `groupPanelItemTemplate` function. The `item`, and `draft` properties are no longer available, use the `item` property instead.
We've released the 1.0.0-beta.2 version containing described changes. |
We published a function that contains the possible solution described in the first post of this thread. |
@SergeyAlexeev do you mind explaining how to use connectProps? |
Usage of |
@DmitryBogomolov Thanks!! that's what I needed. But I still have an issue (I hope you don't mind me asking here). I've created a custom TypeProvider for dropdown...everytime the select changes it loses focus (even with the approach you mentioned)
I'm wondering if I use DataTypeProvider inside the actual component instead of using a Custom DataTypeProvider will solve the issue. Do you know what could be the reason for losing focus? Thanks again |
class SelectTypeProvider extends React.PureComponent {
constructor(props) {
...
this.editor = connectProps(SelectComponent, () => ({ options: this.props.options }));
}
componentDidUpdate() {
...
this.editor.update();
}
render() {
return <DataTypeProvider editorComponent={this.editor} for={this.props.for} />
}
} |
@DmitryBogomolov as I have imagined. Thanks!!! |
Is there an elegant way of accomplishing the same thing using functional components & hooks? I've experimented a bit with React.memo & useRef, but no luck so far. |
@durre I didn't try but following the concept it will work if you put it inside of |
This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. |
Starting with the initial release, our components and plugins contain "...Template" properties, which hold render functions. During alpha releases, we added many features providing rich customization capabilities. Now, many of those render functions are treated as React components: they can have children and an associated key property.
The Grid wraps each render function in the TemplateRenderer component to support passing an associated key property to this function. This causes creation of multiple TemplateRenderer components in the virtual DOM tree, which decreases performance. We are going to fix this problem. However, it will lead to a breaking change.
Suggested Change
...Component
properties that accept a component instead of...Template
properties that accept render functionsDifference between the Component and Render Function
Here is a property receiving a component:
and here is a render function:
If you use a property receiving a component, DataTypeProviter uses React.createElement to create a new React element based on the provided component. It means that if you pass a function to the component attribute, a new component is created each time the Grid is rendered. This causes redundant mounting and unmounting of the component instead of just updating it.
Passing a Render Function as a Component
We don't recommend passing a rendering function to a component property because of the issue described above. However, you can work around this limitation using any state management library. For example, Redux.
If you want to pass the rendering function to a component property and do not want to use a state management library, we advise you to use the following solution to avoid component unmounting.
The original code:
Possible solution:
The text was updated successfully, but these errors were encountered: