department-of-veterans-affairs / va-forms-system-core

VA Forms System Core will be a React library hosted in NPM that will allow engineers and designers to easily interact with Forms inside of vets-website.
https://department-of-veterans-affairs.github.io/va-forms-system-core/
6 stars 4 forks source link

Router Refactor: Conditional Route Logic #560

Open larsmaxwell opened 2 years ago

larsmaxwell commented 2 years ago
  1. Conditional Path logic RouterContext uses conditional path property (ln 33)
    const conditionalPath =
        ((current?.element as ReactElement)?.props as { type: string })
          ?.type === 'conditional';

    instead of just checking for the existence of a conditional property:

      const condition = (
        (current?.element as ReactElement)?.props as { condition: string }
      )?.condition;
  2. RouterContext.tsx currently uses useField when you could probably hook into the Formik context to get the field value. Determine which method is least expensive, and change it if necessary: const field = condition ? useField(condition) : null;