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

ag-grid-solid: Run onMount before createEffect #7100

Open
wants to merge 1 commit into
base: latest
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
64 changes: 32 additions & 32 deletions grid-packages/ag-grid-solid/src/grid/agGridSolid.tsx
Expand Up @@ -43,38 +43,6 @@ const AgGridSolid = (props: AgGridSolidProps) => {
destroyFuncs.length = 0;
});

// we check for property changes. to get things started, we take a copy
// of all the properties at the start, and then compare against this for
// changes.
const propsCopy: any = {};
Object.keys(props).forEach(key => propsCopy[key] = (props as any)[key]);

createEffect(() => {
const keys = Object.keys(props);
const changes: { [key: string]: { currentValue: any, previousValue: any } } = {};
let changesExist = false;

keys.forEach(key => {
// this line reads from the prop, which in turn makes
// this prop a dependency for the effect.
const currentValue = (props as any)[key];

const previousValue = propsCopy[key];
if (previousValue !== currentValue) {
changes[key] = {
currentValue,
previousValue
};
propsCopy[key] = currentValue;
changesExist = true;
}
});

if (changesExist) {
ComponentUtil.processOnChange(changes, gridOptions.api!);
}
});

onMount(() => {

const modules = props.modules || [];
Expand Down Expand Up @@ -124,6 +92,38 @@ const AgGridSolid = (props: AgGridSolidProps) => {
gridCoreCreator.create(eGui, gridOptions, createUiCallback, acceptChangesCallback, gridParams);
});

// we check for property changes. to get things started, we take a copy
// of all the properties at the start, and then compare against this for
// changes.
const propsCopy: any = {};
Object.keys(props).forEach(key => propsCopy[key] = (props as any)[key]);

createEffect(() => {
const keys = Object.keys(props);
const changes: { [key: string]: { currentValue: any, previousValue: any } } = {};
let changesExist = false;

keys.forEach(key => {
// this line reads from the prop, which in turn makes
// this prop a dependency for the effect.
const currentValue = (props as any)[key];

const previousValue = propsCopy[key];
if (previousValue !== currentValue) {
changes[key] = {
currentValue,
previousValue
};
propsCopy[key] = currentValue;
changesExist = true;
}
});

if (changesExist) {
ComponentUtil.processOnChange(changes, gridOptions.api!);
}
});

return (
<div ref={eGui!} style={{height: '100%'}}>
{context() &&
Expand Down