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

a.createContext is not a function #360

Open
SolarisX1337 opened this issue Apr 15, 2024 · 4 comments
Open

a.createContext is not a function #360

SolarisX1337 opened this issue Apr 15, 2024 · 4 comments
Assignees

Comments

@SolarisX1337
Copy link

SolarisX1337 commented Apr 15, 2024

InteractionManagerProvider.tsx:33

Uncaught TypeError: a.createContext is not a function
at 6981 (InteractionManagerProvider.tsx:33:39)
at e (bootstrap:19:32)
at 5144 (ControlledTreeEnvironment.tsx:40:36)
at e (bootstrap:19:32)
at 5447 (Tree.tsx:40:35)
at e (bootstrap:19:32)
at 3735 (TreeItemChildren.tsx:9:14)
at e (bootstrap:19:32)
at 3307 (TreeItemElement.tsx:28:26)
at e (bootstrap:19:32)

This is an error from the console, I don't know if it affects me.
Not sure if this is a bug or a misconfig somewhere in my program but this is interesting non the less, I can't find the file that the error is located, everything looks fine. This is the path webpack://ReactComplexTree/src/controlledEnvironment/InteractionManagerProvider.tsx

@lukasbach
Copy link
Owner

Hey! That is an odd error, createContext is a React global. It's also odd that the path where the error happens is the typescript source file, you should not import the sources, but the built files, but maybe a source mapping is changing the path that is displayed.

Can you share the code where you import the library and render it? I would also be interested in your version of React, your webpack config and tsconfig if possible.

@SolarisX1337
Copy link
Author

Sure thing,

tsconfig.node.json -- This is tsconfig
package.json -- This is the package

App.tsx

import { UncontrolledTreeEnvironment, Tree, StaticTreeDataProvider } from 'react-complex-tree'
import { longTree } from "./data"
import 'react-complex-tree/lib/style-modern.css'

export default function App() {
  return (
    <UncontrolledTreeEnvironment
      dataProvider={
        new StaticTreeDataProvider(longTree.items, (item, data) => ({
   
       ...item,
          data,
        }))
      }
      getItemTitle={(item) => item.data}
      canDragAndDrop={true}
      canReorderItems={true}
      canDropOnFolder={true}
      viewState={{
        "tree-1": {
          expandedItems: ["Fruit"],
        },
      }}
    >
      <Tree treeId="tree-1" rootItem="root" treeLabel="Tree Example" />
    </UncontrolledTreeEnvironment>
  );
}

Main.tsx

import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import "./styles.css";

ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
);

This is written using the Tauri Framework (Might look a bit strange)

@SolarisX1337
Copy link
Author

SolarisX1337 commented Apr 16, 2024

Update: I found code that must of snuck in while troubleshooting earlier

<link href="https://unpkg.com/react-complex-tree/lib/style.css" rel="stylesheet" />
<script src="https://unpkg.com/react-complex-tree/lib/bundle.js"></script>

No wonder why the path was a webpack URI, The Error is no longer present 😄

@lukasbach
Copy link
Owner

Haooy to hear! So has the issue been closed, and I can close this ticket?

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

No branches or pull requests

2 participants