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

Fixed some reactivity bugs #11

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AFatNiBBa
Copy link
Contributor

Made a couple of changes to allow things like the following to work

import AgGridSolid from "solid-ag-grid";
import { SortDirection } from "ag-grid-community";
import { createSignal } from "solid-js";

import "ag-grid-community/styles/ag-grid.css";
import "ag-grid-community/styles/ag-theme-alpine.css";

export default function() {
  const [ get, set ] = createSignal<SortDirection>("asc");
  return <>
    <button onClick={() => set(x => x === "asc" ? "desc" : "asc")}>
      Flip sort
    </button>
    <div class="ag-theme-alpine" style={{ width: "99dvw", height: "99dvh" }}>
      <AgGridSolid
        columnDefs={[
          { field: 'make', sort: get() },
          { field: 'model' },
          { field: 'price' },
        ]}
        rowData={[
          { make: 'Toyota', model: 'Celica', price: 35000 },
          { make: 'Ford', model: 'Mondeo', price: 32000 },
          { make: 'Porsche', model: 'Boxster', price: 72000 },
        ]}
        defaultColDef={{
          flex: 1
        }}
      />
    </div>
  </>
};

The change to columnDefs would have not worked because

  • It would have thrown because of the order in which onMount() and createEffect() were executed inside AgGridSolid
  • The change would have caused an infinite update loop because the columns were not cached

…ore the `createEffect()` because there could be changes even the first time

Memoized the props of `AgGridSolid` to optimize and prevent unwanted notifications
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant