react-feature-flags icon indicating copy to clipboard operation
react-feature-flags copied to clipboard

Error: Uncaught [TypeError: Cannot read property 'filter' of undefined]

Open abacaphiliac opened this issue 3 years ago • 1 comments

fix: throws helpful error instead of trying to call Array.prototype.filter on undefined

instead of providing a sensible fallback value (e.g., empty array []) i thought it would be more helpful to throw an error like you'd see if you try to use a <Link> without a <Router>:

    Error: Uncaught [Error: Invariant failed: You should not use <Link> outside a <Router>]

abacaphiliac avatar Nov 02 '21 17:11 abacaphiliac

@abacaphiliac I am having the following error with my jest test

TypeError: Cannot read property 'filter' of undefined

      78 |
      79 |   it(" Test View component Render", () => {
    > 80 |     const { container } = render(<TestView />);
         |                           ^

My Files:

const { container } = render(<TestView />);

File for Provider in App Level:

<FlagsProvider value={flagsConfigValues}>
      <PageWrapper>
        <Layout
            content={LayoutContent}
        />
      </PageWrapper>
    </FlagsProvider>

Any Help?

masudiiuc avatar Jan 18 '22 05:01 masudiiuc