TLDR, I got an error when integrating between those 3. But when I use Meteor with ChakraUI, it works nicely. But when I add react router, it throw this error
Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
So in Meteor, I wrap the app in client/main.jsx with the ChakraUI provider and Browser Router. Chakra need to wrap the app in their provider base on their docs.
import React from 'react';
import { Meteor } from 'meteor/meteor';
import { render } from 'react-dom';
import { App } from '/imports/ui/App';
import { ChakraProvider } from "@chakra-ui/react"
import { ColorModeScript } from "@chakra-ui/react"
import { BrowserRouter } from 'react-router-dom'
Meteor.startup(() => {
render(
<ChakraProvider>
<ColorModeScript initialColorMode={'dark'} />
<BrowserRouter>
<App/>
</BrowserRouter>
</ChakraProvider>,
document.getElementById('react-target'));
});
Then in imports/ui/App.jsx I put react route switch to render the page. Before that, I put Home.jsx code inside it.
import React from "react";
import {
BrowserRouter as Router,
Switch,
Route,
Link
} from "react-router-dom";
import {Home} from './pages/Home'
export default function App() {
return (
<>
<div>
<Switch>
<Route path="/">
<Home />
</Route>
</Switch>
</div>
</>
);
}
So is there any wrong way in my code to "wrap" the apps?
Thank you