Why do I need to install redux along with react-redux? - npm

If react-redux depends on redux and can't function without it, why would redux not be part of react-redux library?Is it only because someone may want to uninstall react-redux and still want to keep with redux in a react project? Or is there some other logic?

Because Redux is a standalone JS library that can be used with any UI framework (React, Angular, Vue) or even vanilla JS / jQuery. React-Redux is the specific bindings library that lets your React components interact with the Redux store, and there are bindings libraries for other UI layers as well. So, there are separate but related libraries that do different jobs.
Please see my post The History and Implementation of React-Redux and my talk A Deep Dive into React-Redux for more details on what React-Redux does and how it works.

Related

Mocking requests in Storybook React Native

I would like to be able to setup stories for my react native screens, which hooks into the API via react query hooks. I'm using the beta version of storybook react native (6.0.1-beta3).
https://storybook.js.org/addons/msw-storybook-addon, which is what I'd normally use in a react project, won't work because service workers don't exist in react native (if I'm understanding things correctly).
I have also tried installing https://storybook.js.org/addons/storybook-addon-mock/, but wasn't able to get it work (storybook failed with a runtime error when trying to register the plugin... likely a version mismatch).
I might just have to go with a container/dumb component approach for the screens, but that has it's own drawbacks because queries or mutations can be nested in components.
I'm using axios for what it's worth. I've also considered putting the axios instance in a provider so I could modify the instance per test.
Thanks

Can I use flutter in my react native app?

So I have a react native app and was hoping if I could use flutter for some components.
We are using redux for state management and was curious if we could use the same redux store for flutter components.
And for persistence we are using realm, was curious if flutter supports realm.
No you can't use flutter component into react native because both are written in different technology language stack.
Flutter is an open-source mobile application framework that works on
a completely different programming language called Dart, While React
Native lets you build mobile apps using only JavaScript.
Dart is based on c/c++, java and supports things like abstraction,
encapsulation, inheritance, and polymorphism. Flutter team picked
Dart because it matched the way they were building user interfaces,
With Dart bridge, the application size is bigger, but it works much
faster. Unlike React Native with Javascript bridge.
Second Redux is an application architecture, made originally for
JavaScript. Redux provide library for both but we can't use same
redux state for react native and flutter. Redux are written
different for both platform with same functionality and
working(state management)
Realm is also a third party plugin which is available for both
platform but we can't share code between both platform.

Is it possible to use react hooks in react native?

In react documentation it says that the variable and the listener hook must be declared within the component but React native complains when I try to do that.
Is there any way to use the Hooks in React Native?
Or does anyone know if they are going to be implemented in the future ?
Sort of, though useEffect is not working. The current plan is to move to react 16.6 by 0.57.5 and allow people to opt in to using hooks with an option 0.57.5-alpha build. If you want to use hooks now:
Change your react dependency to 16.7.0-alpha in package.json
Clone react
cd react
yarn install
yarn build -- --type=RN_OSS
copy build/react-native to your project's node_modules/react-native/Libraries/Renderer directory.
You can also use this unofficial react-native build with hooks already included. Just remember that useEffect is not working at all with react-native, so you're better off probably waiting. You can read more about this discussion on this github issue.
EDIT: Hooks are coming!!! They are live in React and have been confirmed as a feature shipping in React Native 0.59, you can even use the current release candidate
Yes!
React Hooks are part of the 0.59 release.
Quote from the 0.59 release notes:
React Hooks are part of this [0.59] release, which let you reuse stateful logic across components
There's a quick overview of Hooks, to get you started:: https://reactjs.org/docs/hooks-overview.html
React 16.8.0 is the first release to support Hooks. When upgrading, don’t forget to update all packages, including React DOM. React Native supports Hooks since the 0.59 release of React Native.
No Breaking Changes
Before we continue, note that Hooks are:
• Completely opt-in. You can try Hooks in a few components without rewriting any existing code. But you don’t have to learn or use Hooks
right now if you don’t want to.
• 100% backwards-compatible. Hooks don’t contain any breaking changes.
• Available now. Hooks are now available with the release of v16.8.0.
Only Call Hooks from React Functions
Don’t call Hooks from regular JavaScript functions.
 Instead, you can:
Call Hooks from React function components
Call Hooks from custom Hooks
Some Basic Hooks are mention below
useState
useEffect
useContext
Some Additional Hooks
useReducer
useCallback
useMemo
useRef
useImperativeHandle
useLayoutEffect
useDebugValue
For more information please read following document
https://reactjs.org/docs/hooks-intro.html

React native based app

Which framework should I follow to create react-native based apps or what is the best appropriate way if I want to use Redux for creating new apps.
I just want to build an app using react native along with redux and I am not sure what library should I use for that ?
I know little about Redux thunk and saga but as a newbie I am confused what could be use for my app that gives me more flexible .
From my personal expirience, to develop I use Atom once installed you can add more plugins in order to customize it.
For debug purposes I use a couple of Chrome plugins like React Developers Tools and Redux Dev Tools
As I said, these are my options but there are so many others...

Boilerplate code for setting up Redux on a Expo/CNApp project?

I've used Ignite CLI to bootstrap a simple react native project, and everything from sample components to Redux were set up and ready to go. What's missing from the Ignite project is the ability to use Expo out of the box. So I though I'd look into Expo and Create React Native App, and see if those provide a similar easy out-of-the-box Redux setup.
So does anyone know of any Expo/CNApp boilerplate code for bootstrapping a react-native project, which includes stuff like Redux and sample screens and components?
Expo offers a New Project Template. While it includes fonts, navigation, icons, app loading, push notifications, and some basic screens, it does not include Redux.
There are good Redux examples from Redux.org. I also found this repo and the associated tutorial to be good a example of how to integrate Redux into a React Native app.