Questions tagged [easy-peasy]

"Easy Peasy provides you with an intuitive API to quickly and easily manage the state for your React application. Batteries are included - no configuration is required to support derived state, API calls, performance optimisation, developer tools etc."

50 questions
1
vote
0 answers

Problem with components getting updated using state

https://streamable.com/c1ygkw I have a problem with images not being update in components even though the state of the items they receive their info from changes. It starts here after picking an image from my computer and saving it const…
dnAir
  • 197
  • 1
  • 9
1
vote
1 answer

TypeError: Proxy has already been revoked. No more operations are allowed to be performed on it

I use easy-peasy v5 on react-native for the Store and every time I try to call an action within a thunk it throws an error. fetch: thunk(async (actions, teamId, { getStoreActions }) => { // get data of all items /* ... */ try { …
Shayan
  • 11
  • 4
1
vote
1 answer

I don't understand the execution flow of redux thunks with chaining

This is an example code from the easy peasy docs but the same question goes for createThunk from redux-toolkit: function MyComponent() { const saveTodo = useStoreActions(actions => actions.todos.saveTodo); const onSaveClick = useCallback( //…
morh
  • 101
  • 1
  • 9
1
vote
1 answer

How can I use easyPeasy's useStoreState in Storybook?

I want to create a story in storybook for my component that uses a state from easyPeasy. const label = useStoreState((state) => state.localeModel.getLabel) When I try to create the story I am getting an error in storybook An error occurred trying…
1
vote
1 answer

Can you use a Map instance as an easy-peasy store property?

ie. const store = { values: new Map(), // (gross trivial accessor) setValue: action( (state, payload) => { state.values.set(payload.key, payload.value); } } I'm curious because easy-peasy uses a Proxy on the store object…
Joel M
  • 353
  • 2
  • 10
1
vote
2 answers

How to delete records from a model referenced by a different model?

I have two models, where model A references items in model B. When I delete items from model B, react rerenders before I can update model A to also delete the referenced items. Example: I have a feed. The feed is made up of different types of items.…
david_adler
  • 9,690
  • 6
  • 57
  • 97
1
vote
1 answer

React store problem using easy peasy, unexpcted rendering mess up the model in store

When I call an action, first time data is loaded perfectly fine. Component re-renders again and messes up the state. Default State menu_detail: { error: null, menu_id: 0, detail: {} } Working State menu_detail: { error: null, …
Farman Ali
  • 97
  • 10
1
vote
1 answer

This expression is not callable. Type 'Thunk' has no call signatures

Here is my code. I want to call action and above error is keep coming. const action = useStoreActions( (actions : StoreModel) => actions.collections.fetchCollections); useEffect( () => { action() },[]) This is my collections object and I wants…
1
vote
1 answer

Error: First argument to `createDraft` must be a plain object, an array, or an immerable object

Home.js import React, { useState, useEffect } from 'react' import './HomeCss.css' import { Card, Button, Container, Row, } from 'react-bootstrap' import Axios from 'axios' import { useStoreActions, useStoreState } from 'easy-peasy' const Layout =…
1
vote
1 answer

Functional component props/state/store not updated in function - what's a viable alternative?

First off some description of what I need to achieve. I show information in front-end (React) that mostly corresponds to database rows and the user can do regular CRUD operations on those objects. However, I also add some dummy rows into the JSON…
wanaryytel
  • 3,352
  • 2
  • 18
  • 26
1
vote
1 answer

Easy-peasy [redux] toggle state from actionOn with a delay

I'm trying to figure out, how to make a self-resetting model with easy-peasy. Basically I want to call setInGridAnimation once and then have it reset in 400ms automatically so I don't have to worry about it any more. The reason is obviously that…
wanaryytel
  • 3,352
  • 2
  • 18
  • 26
1
vote
0 answers

How to call an action repeatedly with React and Easy Peasy

I have a functional component which displays a list of item. The items are fetched via Ajax. I'm using React with Easy Peasy, a state management library. const MyList = () => { const {fetchItems} = useStoreActions(actions => actions.myStore); …
Alexis Romot
  • 524
  • 6
  • 19
0
votes
1 answer

Correct way to provide a store to React app when using React Router

I have an issue with my store state being undefined (or something to do with the store being undefined) when I try to access the state to determine if a user is logged in. I am using easy-peasy: const store = createStore({ user: { loggedIn:…
James Young
  • 5
  • 1
  • 1
0
votes
0 answers

Using react testing library and easy-peasy state management

I am using easy peasy and RTL for testing and am getting error TypeError: Cannot read properties of undefined (reading 'subscribe') when running the test. The app works otherwise in the browser. Anyone know of any solutions? I was doing a test…
0
votes
1 answer

Easy-Peasy / NextJS / React maybeGetServerSnapshot is not a function

Running the latest easy-peasy (5.2.0) along with the lates major versions of NextJS (12.1.6) and React (18.1.0) causes easy-peasy to throw an error TypeError: maybeGetServerSnapshot is not a function` when calling their native…