Comments (3)
import { StoreProvider as EasyPeasyStore } from "easy-peasy"
import store from "../../store"
import { ReactNode } from "react"
export default function StoreProvider({ children }: { children: ReactNode }) {
return <EasyPeasyStore store={store}>{children}</EasyPeasyStore>
}
// First, you must make a client component for EasyPeasyStore and then import your StoreProvider in the root layout.(jsx|tsx) file. With this, you have a working store. Edit "Devtools just work fine as well" I myself use this approach for a huge project so, it works. See layout.tsx file
```import "./globals.css"
import { Inter } from "next/font/google"
import StoreProvider from "../components/core/StoreProvider"
const inter = Inter({ subsets: ["latin"] })
export const metadata = {
title: "Create Next App",
description: "Generated by create next app"
}
export default function RootLayout({
children
}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<body className={inter.className}>
<StoreProvider>{children}</StoreProvider>
</body>
</html>
)
}
// You need to use EasyPeasyStore in a client component because it uses React Context under the hood and it's not available server side. I imported my custom StoreProvider which uses EasyPeasy StoreProvider under the hood.
from easy-peasy.
Hey @TrueXPixells ! Sounds like a good example to have. In theory, it should not be very different from the traditional next setup.
Reading the docs, it seems that the root layout
will be replacing the old _app.jsx
. If I understand correctly, the <StoreProvider store={store}>
should be placed inside your root layout.jsx
.
Haven't tested the new app structure with Next.js yet, but if you get an example up and running - feel free to submit a PR with the new example 👍
from easy-peasy.
I didn't know that contexts were unsupported in Next.js 13. I can't seem to find an alternative to contexts, so creating your own client Store
-component seems to be the approach.
from easy-peasy.
Related Issues (20)
- undefined store on "contextmenu" event HOT 2
- Cannot assign other store action to property HOT 4
- RangeError "Maximum call stack size exceeded" on clone function HOT 3
- Unable to alias `Unstable_EffectOn` type
- Inform users about immer workings for complex objects HOT 4
- Disable merge in easy peasy HOT 2
- HMR using Vite: module is not defined HOT 1
- Persist state with boolean false as default value? HOT 1
- Updating State HOT 2
- Broken in NextJS 13 with React 18 HOT 6
- Performance: Modifying data is too time-consuming HOT 3
- Property 'user' does not exist on type 'StateMapper<FilterActionTypes<{}>>' HOT 2
- Support for collection of nested models HOT 5
- Is it still maintained? HOT 2
- TypeError: proxy handler is null HOT 3
- Computed props which depend on computed props that consume store state don't update as expected
- Possible bug due to unnecessary rerenders HOT 5
- Inquiry Regarding Bundle Size in easy-peasy v6.0.4 HOT 1
- RIP
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easy-peasy.