Skip to content

Commit

Permalink
fix(admin-ui): Use generics in ReactDataTableComponentProps (#2500)
Browse files Browse the repository at this point in the history
  • Loading branch information
barakamwakisha authored Nov 3, 2023
1 parent ec4f68d commit 730a103
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ React components will receive the value of the current column as the `rowItem` p
import { ReactDataTableComponentProps } from '@vendure/admin-ui/react';
import React from 'react';

export function SlugLink({ rowItem }: ReactDataTableComponentProps) {
const slug: string = rowItem.slug;
export function SlugLink({ rowItem }: ReactDataTableComponentProps<{ slug: string }>) {
const slug = rowItem.slug;
return (
<a href={`https://example.com/category/${slug}`} target="_blank">
{slug}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ e.g. the `Product` object if used in the `product-list` table.
import { ReactDataTableComponentProps } from '@vendure/admin-ui/react';
import React from 'react';

export function SlugWithLink({ rowItem }: ReactDataTableComponentProps) {
export function SlugWithLink({ rowItem }: ReactDataTableComponentProps<{ slug: string }>) {
return (
<a href={`https://example.com/products/${rowItem.slug}`} target="_blank">
{rowItem.slug}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export interface ReactDataTableComponentConfig {
* @description
* The props that will be passed to the React component registered via {@link registerReactDataTableComponent}.
*/
export interface ReactDataTableComponentProps {
rowItem: any;
export interface ReactDataTableComponentProps<T = any> {
rowItem: T;
[prop: string]: any;
}

Expand All @@ -60,7 +60,7 @@ export interface ReactDataTableComponentProps {
* import { ReactDataTableComponentProps } from '\@vendure/admin-ui/react';
* import React from 'react';
*
* export function SlugWithLink({ rowItem }: ReactDataTableComponentProps) {
* export function SlugWithLink({ rowItem }: ReactDataTableComponentProps<{ slug: string }>) {
* return (
* <a href={`https://example.com/products/${rowItem.slug}`} target="_blank">
* {rowItem.slug}
Expand All @@ -79,7 +79,7 @@ export interface ReactDataTableComponentProps {
* tableId: 'product-list',
* columnId: 'slug',
* props: {
* foo: 'bar',
* foo: 'bar',
* },
* }),
* ];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ReactDataTableComponentProps } from '@vendure/admin-ui/react';
import React from 'react';

export function SlugWithLink({ rowItem }: ReactDataTableComponentProps) {
const slug: string = rowItem.slug;
export function SlugWithLink({ rowItem }: ReactDataTableComponentProps<{ slug: string }>) {
const slug = rowItem.slug;
return (
<a href={`https://example.com/category/${slug}`} target="_blank">
{slug}
Expand Down

0 comments on commit 730a103

Please sign in to comment.