easy-peasy icon indicating copy to clipboard operation
easy-peasy copied to clipboard

React 18

Open OlekRia opened this issue 3 years ago • 30 comments

After upgrading to react version 18, easy-peasy stopped working. When we call API it doesn't rerender a component which uses useStoreState hook.

OlekRia avatar Apr 02 '22 17:04 OlekRia

@w3bdesign Oh, it's not about the typing... However, of course i am not acknowledge good with a source code. But the problem is that it doesn't work properly. It seems because react 18 becomes "asyncronous"

OlekRia avatar Apr 10 '22 04:04 OlekRia

Experiencing the same issue after changing to use reacts createRoot

Does not work
------------------------
const root = createRoot(document.getElementById("root"));
root.render(
  <React.StrictMode>
    <BrowserRouter>
      <StoreProvider store={store}>
        <App />
      </StoreProvider>
    </BrowserRouter>
  </React.StrictMode>
);
This works
-------------------

ReactDOM.render(
  <React.StrictMode>
    <StoreProvider store={store}>
      <BrowserRouter>
        <App />
      </BrowserRouter>
    </StoreProvider>
  </React.StrictMode>,
  document.getElementById("root")
);

benkissi avatar Apr 10 '22 16:04 benkissi

i have the same problem here. Alse using ReactDOM.render is not an optimal solution because we're missing all the new features introduced on react 18

c-ctkd avatar Apr 28 '22 11:04 c-ctkd

i have the same problem here. Alse using ReactDOM.render is not an optimal solution because we're missing all the new features introduced on react 18

Am I guess... Seems this issue is not resolvable by easy-peasy ?

OlekRia avatar Apr 28 '22 14:04 OlekRia

using ReactDOM.render works. Also, for me, it does not work only the in the development environment but works fine when you build using npm run build I am using "easy-peasy": "5.0.4" "react": "18.1.0" "@types/react": "18.0.8"

codydeny avatar May 05 '22 06:05 codydeny

Removing React.StrictMode works for me, so that easy-peasy store updates are fired again.

zawupf avatar May 11 '22 08:05 zawupf

Removing React.StrictMode works for me, so that easy-peasy store updates are fired again.

I guess the reason of existing React.Strict mode is quite respectful. I am afraid, your advice looks like not a solution.

OlekRia avatar May 11 '22 12:05 OlekRia

For sure that's just a workaround, until the underlying bug is fixed.

zawupf avatar May 11 '22 12:05 zawupf

For typescript users, you can try to use foca which support react 18 and type strong enough. Foca also based on redux + react-redux + immer

geekact avatar May 18 '22 09:05 geekact

I don't use typescript. Because I am fed up with it. And I don't read Chinese. And don't get how a programmer may write a documentation using another language than English.

OlekRia avatar May 18 '22 11:05 OlekRia

I don't use typescript. Because I am fed up with it. And I don't read Chinese. And don't get how a programmer may write a documentation using another language than English.

@OlekRia @w3bdesign Yep, Chinese is not friendly for west countries, I just searched this framework today, and actually I think it's time to write English documentation since foca is great enough to show it to people who also love redux in the world.

geekact avatar May 18 '22 13:05 geekact

You know. Modern React Toolkit isn't bad as well and mature.

OlekRia avatar May 18 '22 14:05 OlekRia

Guys, thanks for your advertisement. But I am interested in easy-peasy.

OlekRia avatar May 18 '22 20:05 OlekRia

did you guys find a solution? im looking to upgrade react, but this is a showstopper.

orbachar avatar Jun 23 '22 07:06 orbachar

@ctrlplusb any update on it?

1alexvash avatar Jul 10 '22 06:07 1alexvash

Looking for an update, as while using next you can't really toggle strict mode, or any of the React 18 setup

1alexvash avatar Jul 10 '22 06:07 1alexvash

@ctrlplusb Firstly, I love this lib. Use it on a few projects and it's helped me loads.

I'm keen to look at react 18 support, if it's something you don't have time for - is there any way I can help?

liamdefty avatar Jul 19 '22 20:07 liamdefty

Hello everyone! I am having an issue in using easy-peasy in react 18, like for example when I change the value in the input it does not working properly the calling of api is not working also, can please help with this or am i the only experiencing this bug?

juneroy1 avatar Aug 07 '22 11:08 juneroy1

Am also getting the same issue with easy-peasy in react 18

larrykn avatar Aug 15 '22 13:08 larrykn

@ctrlplusb I would really love to use easy-peasy, maybe by any chance you could look into this bug ?

Digital-Coder avatar Sep 02 '22 11:09 Digital-Coder

Looks like the library is dead. leaving...

apuatcfbd avatar Sep 13 '22 10:09 apuatcfbd

Hi ya'll. I'm going to begin looking into React 18 support. My initial intuition is that this might constitute a breaking change. I'll look into how other popular state libraries are handling this transition.

ctrlplusb avatar Sep 15 '22 06:09 ctrlplusb

@ctrlplusb Man... It's too late...

OlekRia avatar Sep 15 '22 06:09 OlekRia

~ redacted this comment, as I figured out a breaking change isn't required ~

ctrlplusb avatar Sep 15 '22 14:09 ctrlplusb

Ok, some good news. The React team released a shim which allows me to do backwards support for React 16 and 17.

I've done an initial integration and all the source tests are passing. 🎉

I still need to fix the TypeScript definitions, and also need to look into the SSR story as my initial read on this is that it may need additional work. Looking good thusfar.

If you are happy to be an alpha tester on this please ping in this issue.

ctrlplusb avatar Sep 15 '22 15:09 ctrlplusb

Yeah, I definitely need to extend the provider to support SSR for React 18.

So if anyone is doing an SPA, please volunteer for alpha testing.

I'll ping when the SSR story is sorted for wider testing.

ctrlplusb avatar Sep 15 '22 15:09 ctrlplusb

Screenshot 2022-09-15 at 23 57 22

😎

ctrlplusb avatar Sep 15 '22 15:09 ctrlplusb

Ok ya'll. Anyone running an SPA, please could you test this alpha release;

yarn add [email protected]

CodeSandbox Example

ctrlplusb avatar Sep 15 '22 16:09 ctrlplusb

On face value the SSR support doesn't look difficult. We should be able to land this very soon if user feedback goes well in testing the alpha releases.

ctrlplusb avatar Sep 15 '22 16:09 ctrlplusb

Ok ya'll. Anyone running an SPA, please could you test this alpha release;

I have tested the alpha version and it works smoothly. Our store is not too small. It has many actions, thunks, thunkOns, computed states etc. The store keeps much data.

Thank you very much for restarting work on this very cool library.

rainerbruemmer avatar Sep 16 '22 09:09 rainerbruemmer