As a web developer, can you explain why React is needed?
In the early days of the internet, web sites were essentially made of static HTML files. Web servers were little more than file servers, when a user would come to a url, the web server would simply fetch it, and send it to the user via their browser, along with all kind of assets, like fonts and images.
The functionality of this kind of web pages are very limited, so eventually the web became more dynamic. When people would visit a page or interact with a form, instead of just fetching data, the server could perform an operation and prepare some content on demand. That content would still be sent to the user’s browser. There could also a little bit of code running on the browser, to animate pages, handle form and what not, but not very much.
So up until around 2010, that was the dominant model. Code could be involved to generate content but the browser wouldn’t do much, most of the logic would happen on servers which would just send prepared content to the browser.
However, in the early 2010s, this paradigm started to shift. With HTML5/CSS3, the browser became much more capable, and so people started to move the logic that would generate content from the server to the browser. Instead of sending a whole styled HTML page, a web server could just send the data needed to create it. Then, code could run on the browser to actually turn that data into HTML. That browser code could also update what the user would see, making just the required data calls.
So, in the early to mid 2010s, front-end code would typically:
- render complex web pages from data retrieved from back-end,
- simulate “navigation” between different views: when the user would do some actions, the entire page would change, the url would update etc. but without actually loading a new page from the server.
- maintain the state of an application: the application could track certain things about the user and the session, and won’t have to reload that information from the server all the time.
- dynamically update both contents and style of a web page.
Now, all of this is possible to do in “vanilla javascript”. But it’s really cumbersome to implement it, and especially tricky to do it in a performant way. There are millions and millions of “web apps” that are replacing the static “web sites” of old, and which all need to dynamically render content. Should developers reimplement that from scratch each time?
Enter the web frameworks such as React. These frameworks are abstractions that let the developers focus on the logic of their web app (where the data comes from, how content is organized) without being tied to the nitty gritty. Web frameworks make developers organize their code in building blocks called modules or components. Somebody could write a header component and someone else building a page could reuse that header component. And a third developer could change the header component, and that change would be reflected everywhere the component is used. Folks could also build 3rd party libraries compatible with the web framework ecosystem, that would address common problems that many developers face. For instance, someone could create a date picker component (a notably tricky interface) that anyone can reuse and customize. Or create a solution to deal with very long pages by only rendering what is in the browser viewport, and creating/deleting elements as a user would scroll.
To have the support of this ecosystem is a huge productivity boost. There are millions of developers who work with React, and the most popular React libraries are very elegant solutions to hard problems(the same could be said of Angular, Vue etc. though their communities are a bit smaller).
React and web frameworks aren’t exactly needed, in fact there is a reverse trend in the last couple of years to go back to server generated content in some cases or to only use vanilla javascript, but it’s a very solid foundation to build a web app.
Comments:
1- The specific rationale for React is state management and efficient page updates, it’s underlying power comes not just from the structure and tooling provided by it being a framework, but also the shadow-DOM and component lifecycle that along with state management empower greater interactivity without very slow inefficient page updates.
2- React isn’t needed, but it is a great framework that can reduce the amount of work you do in making a website/webapp.
React is great for widgets and implementing patterns. You can keep data/text separate from structure and behavior. React, angular and vue are all popular frameworks. Before that we used stuff like dust, handlebars, jQuery and UI libraries like dojo and jQuery UI.
Developers are always looking for ways to be more efficient and more maintainable. React is a current iteration tool for being more efficient.
3- It is needed as a pattern for the devs to create packages that will works (The React packages). In NPM there are many packages, but all them are following its own logic, docs or no docs, they are based on another packages, etc. With things like React, you are somehow limited to follow its rules and you are entering its ecosystem which is good. This is true for all frameworks/libraries.
React also has some configurations which follows the best practices (create-react-app, NextJS, etc), but this is the same and for others.
The difference is that React is close to JS and there is a lot of freedom, what to use like a package, starter pack, use or not Typescript
- React Weekly Issue 42by This Week In I/O (Reactnative on Medium) on July 3, 2022 at 2:51 pm
Welcome to the 42nd issue of React Weekly, weekly roundup of the latest React and React Native links and tutorials.Continue reading on React Weekly »
- React Weekly Issue 42by This Week In I/O (React on Medium) on July 3, 2022 at 2:51 pm
Welcome to the 42nd issue of React Weekly, weekly roundup of the latest React and React Native links and tutorials.Continue reading on React Weekly »
- React: useEffect and useStateby Ann Omao (React on Medium) on July 3, 2022 at 2:38 pm
Hooks were introduced in React version 16.8. Hooks are functions that let you use state and other React features without having to write…Continue reading on Medium »
- Do I need to install create-react-app locally or globally?by /u/TheRNGuy (React – A JavaScript library for building user interfaces) on July 3, 2022 at 2:20 pm
submitted by /u/TheRNGuy [link] [comments]
- Top UI Frameworks for Angular and react.by Shrihari Mohan (React on Medium) on July 3, 2022 at 2:06 pm
Here are the frameworks you should know before you start your next project. Most common ones comes last in the list. You should never use…Continue reading on Medium »
- Does React-dnd support multiselect?by /u/maxifederer (React – A JavaScript library for building user interfaces) on July 3, 2022 at 1:50 pm
https://stackoverflow.com/questions/55750718/how-to-drag-drop-multiple-elements-in-react I was trying to select multiple items, but it doesn't seem to support it. Can you easily swap React-dnd with React-beautiful-dnd? I already have a big application at hand and I am using React-dnd, so I am wondering how difficult it would be to swap. I see a solution for react-draggable, but not react-dnd. https://codepen.io/markvital/pen/vYNZXgW?editors=001 submitted by /u/maxifederer [link] [comments]
- Express & Typescript ile JWTby Alperen Bayramoğlu (React on Medium) on July 3, 2022 at 1:10 pm
JWT (JsonWebToken), RFC 7519 standartı ile tanımlanan eşler arası iletişimin güvenliğini JSON objesi ile sağlar. JWT’te veri gizlenmez…Continue reading on Medium »
- Has anyone used React Native for building TV apps?by /u/jazilzaim (React Native - Building Native Mobile Apps w/JavaScript) on July 3, 2022 at 12:59 pm
Has anyone used React Native to build Android TV or Fire TV apps? If so, I'm curious to hear your thoughts for production use! How was it like working with the D-Pad? Or is it better to go with native Android for this type of project? submitted by /u/jazilzaim [link] [comments]
- Run NodeJS and ReactJS Concurrentlyby Yoonhlee (React on Medium) on July 3, 2022 at 12:18 pm
When developing a full-stack application, you need to run them separately which can be stressful especially when you have to go back and…Continue reading on Medium »
- How to use redux toolkit in react native || #reactnative @Intellect Dev...by /u/Ok_Actuator_4774 (React Native - Building Native Mobile Apps w/JavaScript) on July 3, 2022 at 12:13 pm
submitted by /u/Ok_Actuator_4774 [link] [comments]
- GSoC’22 Week 1 with SCoRELabby Janvi thakkar (React on Medium) on July 3, 2022 at 11:54 am
The community bonding period went awesome. I have other partner contributors on the same project. We all had an unofficial meeting to know…Continue reading on SCoRe Lab »
- What’s new in Next.js 12.2?by Claudio marzella (React on Medium) on July 3, 2022 at 11:36 am
Next.js, it’s a React framework that help you in a construction of blocks. When you are developed a block in React there are multiple…Continue reading on Medium »
- 3 usecases for useRef in 3 minutesby /u/Web-devil (React – A JavaScript library for building user interfaces) on July 3, 2022 at 11:29 am
submitted by /u/Web-devil [link] [comments]
- Performance Optimization Strategies Inside React You Don’t Knowby bytefish (React on Medium) on July 3, 2022 at 11:21 am
The Road to be a React Champion.Continue reading on Medium »
- GitHub: Reactby Swarnalataroydeb Wikiance (React on Medium) on July 3, 2022 at 11:14 am
About GitHubContinue reading on Medium »
- The easiest way to prefetch links and fix fetch waterfalls in react-query, useSWR, Apollo-client or…by Howard (React on Medium) on July 3, 2022 at 9:54 am
TL;DRContinue reading on Medium »
- guys i am getting this error. warn Package react-native-vector-icons has been ignored because it contains invalid configuration. Reason: "dependency.assets" is not allowedby /u/maddy-tech (React Native - Building Native Mobile Apps w/JavaScript) on July 3, 2022 at 9:26 am
submitted by /u/maddy-tech [link] [comments]
- Built a pixel art app in Reactby /u/jpsworkshop (React – A JavaScript library for building user interfaces) on July 3, 2022 at 8:05 am
Hi, I built a pixel art app in React with express and MySQL on the backend, and as a new developer would love to get some feedback. https://20squared.pitans.co.uk/ Thanks submitted by /u/jpsworkshop [link] [comments]
- If I use React Router, is it still a SPA?by /u/raulalexo99 (React – A JavaScript library for building user interfaces) on July 3, 2022 at 5:40 am
Or a SPA should not rely on routing? submitted by /u/raulalexo99 [link] [comments]
- Stuck with proper type for child componentsby /u/Red3nzo (React – A JavaScript library for building user interfaces) on July 3, 2022 at 5:32 am
The following error keep popping up when I compile, Type '{ children: Element; }' is not assignable to type 'IntrinsicAttributes & ReactNode'. I'm working on a state management Class with Mobx & I'm using React Context to pass the class around with the active state. Below I have a file that is essentially my `GlobalStore` that wild keep all the active state classes alive. // Provider without children typed throws `Type '{ children: Element; }' is not assignable to type 'IntrinsicAttributes & ReactNode'. Type '{ children: Element; }' is missing the following properties from type 'ReactPortal': key, type, propsts(2322)` export const StoreProvider = (children) => ( <StoreContext.Provider value={useGlobalStore()}>{children}</StoreContext.Provider> ); // Provider with what I think is the proper type export const StoreProvider = (children: React.ReactNode) => ( <StoreContext.Provider value={useGlobalStore()}>{children}</StoreContext.Provider> ); I'd think that would work but since I'm adding this provider in my root component which I cleverly named `Root` then throws the error I've state on the first line of this post. // Root.tsx const Root = () => { let location = useLocation(); let state = location.state as { backgroundLocation?: Location } return ( <OStoreProvider> // <---- Error occurs here 🙁 <div className='main_container'> <ApplicationGlobalStyle /> <Routes location={state?.backgroundLocation || location}> <Route path="/" element={<HomeScreen />} /> </Routes> {state?.backgroundLocation && ( <Routes> <Route path="/creation" element={<BaseModal />} /> </Routes> )} </div> </StoreProvider> ); } submitted by /u/Red3nzo [link] [comments]
- Step-by-step guide to translation in React Nativeby Saad Khan (Reactnative on Medium) on July 3, 2022 at 5:14 am
In this short guide, I will try to document the following —Continue reading on Medium »
- flex is messing up my layoutsby /u/mrdanmarks (React Native - Building Native Mobile Apps w/JavaScript) on July 3, 2022 at 2:10 am
its either full screen or collapse everything i read somewhere it needs to be flex all the way down, now im hunting gremlins trying to flex everything to either 0 or 1 in hopes my error message text sit under my input text without overlaping... submitted by /u/mrdanmarks [link] [comments]
- Placing interactive D3 graph into React websiteby /u/soconfusedwith_react (React – A JavaScript library for building user interfaces) on July 3, 2022 at 12:11 am
Hey all - help requested. I'm using a form of this graph and trying to place it into a React website, but nothing I'm doing seems to be working. I'm trying to retain the interactivity - toggles, search bar - but html to React packages aren't working and I don't know what else to try. Helmet and dangerouslysetinnerhtml both have issues: the former kept returning with errors for "Property 'class' does not exist" and I couldn't get the latter to accept any CSS. Is there anything else I can try? I'm a beginner with React. submitted by /u/soconfusedwith_react [link] [comments]
- useState and useMemoby /u/Pengwyn2 (React – A JavaScript library for building user interfaces) on July 2, 2022 at 10:01 pm
Hi, So I have an issue I am not sure how to resolve. I want the ability to update multiple states at the same time, however only a subset of those states are used as dependencies for a useMemo. If I bring these together into a collection object and make that object a useMemo dependency, then any setState on the collection object will call a new expensive computation even if the child states that would otherwise not call a new expensive computation did not change. What are some suggestions on how to deal with this please? Thanks submitted by /u/Pengwyn2 [link] [comments]
- React Native Development Servicesby MTCPE For You (Reactnative on Medium) on July 2, 2022 at 9:46 pm
Yojji offers several React Native development services to companies interested in cross-platform app development. With React Native, you…Continue reading on Medium »
- Anyone using NX? TurboRepo as mono repo structure ? I know Lerna and yarn workspaces are good but wanted to know thoughts on using the above two?by /u/Atta-rizwan (React Native - Building Native Mobile Apps w/JavaScript) on July 2, 2022 at 7:33 pm
submitted by /u/Atta-rizwan [link] [comments]
- What do you guys think of doing grids and columns like this?by /u/ThisSoFrustrating (React – A JavaScript library for building user interfaces) on July 2, 2022 at 6:39 pm
Will this be good or okay for responsivness for phone and ipads? export const LandingSection = ()=>{ return( <div className="landing-section-row"> <p className="section-title">my section title</p> <div className="landing-section-column">Hello 1</div> <div className="landing-section-column">Hello 2</div> <div className="landing-section-column">Hello 3</div> <div className="landing-section-column">Hello 4</div> <div className="landing-section-column">Hello 5</div> <div className="landing-section-column">Hello 6</div> <div className="landing-section-column">Hello 7</div> <div className="landing-section-column">Hello 8</div> </div> ) } Wrapper of the <div> row .content-wrapper{ max-width: 1400px; margin:auto; } .landing-section-row{ width: 100%; } .landing-section-column{ width: 325px; margin-bottom: 20px; margin-left: 20px; float:left; background-color: yellow; height:200px; } submitted by /u/ThisSoFrustrating [link] [comments]
- I made a library for Snapchat-like filters, AR lenses, and real-time facial animationsby /u/xrhonin (React Native - Building Native Mobile Apps w/JavaScript) on July 2, 2022 at 6:04 pm
submitted by /u/xrhonin [link] [comments]
- React Native or Flutter?by /u/thecodingpie (React Native - Building Native Mobile Apps w/JavaScript) on July 2, 2022 at 5:02 pm
Hey I am a React dev who is thinking of branch out to try mobile app development. I need genuine opinions from you guys on what should I choose either Flutter or React Native... Because React Native is awesome but it converts everything to its corresponding native elements if i am not wrong. On the other hand flutter controls every pixel so that your app looks same on both os + it also gives you opportunity to have platform specific widget if you need that. So it's really confusing on which technology to learn. I tried flutter and learned a bit of dart too. So should I move with flutter or should I choose react native. One more thing is that even Flutter is good in terms of performance (also new React Native) but no companies are not considering it to create app. But Discord and Flipkart are using RN. This also confuses me. Hope someone will give an unbiased reply... submitted by /u/thecodingpie [link] [comments]
- Why horizontal scrolling doesn't work when child component when using panResponder?by /u/Bimi123_ (React Native - Building Native Mobile Apps w/JavaScript) on July 2, 2022 at 3:51 pm
So, I have a flatlist positioned horizontally where I show a few images. User should be able to scroll through them and then to close that view (modal) user should simply drag/swipe down. I use panResponder to drag modal down and at a certain coordinate it closes. The issue is that somehow flatlist scroll function is stopped by the panResponder. Flatlist scroll only works in some random cases. Here is the StackOverflow link to my post: react native - Why horizontal scrolling doesnt work when child component use panResponder animations? - Stack Overflow submitted by /u/Bimi123_ [link] [comments]
- Login With Regex Expo React Nativeby Muralitharan A (Reactnative on Medium) on July 2, 2022 at 11:31 am
Login Screen with React Native appContinue reading on Medium »
- what is queryKey in useQueryby /u/HaveNoIdea20 (React – A JavaScript library for building user interfaces) on July 2, 2022 at 9:55 am
What is beginner friendly explanation of queryKey in useQuery() submitted by /u/HaveNoIdea20 [link] [comments]
- Adding Objective C header file and .a static librariesby /u/Master_Department_79 (React Native - Building Native Mobile Apps w/JavaScript) on July 2, 2022 at 9:22 am
Hi guys, I have a Bluetooth device that I bought on their website and they provided me with an OBJECTIVE C SDK(header file and.a static libraries) to import in Xcode. I tried this using Swift and it works; the Bluetooth device and the application that I developed are now connected via Bluetooth. I really want to know if this is possible to work in React Native or any cross-platform framework. Is there any chance that I can import an Objective C header file and a static library into React Native? submitted by /u/Master_Department_79 [link] [comments]
- How to build a great App as a Solo Developer — Week 3: Data designby Christopher Schaumloeffel (Reactnative on Medium) on July 2, 2022 at 8:56 am
After outlining what the app should look like, we’ll now focus on how the app should work like. This week’s article covers the design of…Continue reading on Medium »
- How to use kotlin with TurboModules in react native?by /u/BraveEvidence (React Native - Building Native Mobile Apps w/JavaScript) on July 2, 2022 at 8:53 am
The traditional way of adding kotlin lib in gradle files does not work. More info here https://github.com/react-native-community/RNNewArchitectureApp/issues/14 submitted by /u/BraveEvidence [link] [comments]
- Please rate and comment on my portfolio!by /u/original_kimchi (React – A JavaScript library for building user interfaces) on July 2, 2022 at 8:12 am
Dear Redditors, I hope this post finds you well. https://youngjun827.github.io/ Any feedback would be greatly appreciated. Thank you guys in advance! submitted by /u/original_kimchi [link] [comments]
- How to call swift class from objective-c++?by /u/BraveEvidence (React Native - Building Native Mobile Apps w/JavaScript) on July 2, 2022 at 8:01 am
Can some help me with this https://stackoverflow.com/questions/72837318/how-to-call-swift-class-from-objective-c?noredirect=1#comment128651528_72837318 submitted by /u/BraveEvidence [link] [comments]
- Rolling back from bare workflow expo Appby /u/francesco-ionico (React Native - Building Native Mobile Apps w/JavaScript) on July 2, 2022 at 5:51 am
Hi everyone! While trying to make Facebook login in my fully managed react native expo App, I tried to install this library react-native-fbsdk-next, that adds custom native code with the Facebook SDK. I followed this official guide to make it work with expo. Everything was working fine both in iOS and Android, but then I decided to to do a step back to the fully managed workflow and make the login just with OAuth2 implementation with expo-auth-session. I tried to delete all files related to the prebuilt iOS and Android projects, I run my new solution in Expo Go and it is working. I then made an official build and in iOS everything works, but in Android the App crashes at startup! The error is this: The SDK has not been initialized, make sure to call FacebookSdk.sdkInitialize() first! It seems that some piece of the Facebook SDK is still present in my app and got compiled and run! Do you have any idea on what to do to remove it completely? I don’t need the full SDK! submitted by /u/francesco-ionico [link] [comments]
- Flutter Vs React Native — Which Framework is Better?by Sannan Malik (Reactnative on Medium) on July 2, 2022 at 4:20 am
In the Flutter vs. React Native debate, there are many pros and cons to each. While Flutter is more widely used among junior developers…Continue reading on Medium »
- 8 Things that should be Considered While Choosing A React Native Agencyby MTCPE For You (Reactnative on Medium) on July 1, 2022 at 8:33 pm
Are you struggling to find a competent react-native agency that could match your requirements? Are you guilty of hiring react native app…Continue reading on Medium »
- The Best Reasons to Develop React Native Appsby MTCPE For You (Reactnative on Medium) on July 1, 2022 at 8:32 pm
Statistical data says nearly a hundred thousand apps are released in a single month. New apps are launched every day and many older ones…Continue reading on Medium »
- Want To Optimize React Native Performance? The Dos And Don’tsby MTCPE For You (Reactnative on Medium) on July 1, 2022 at 8:32 pm
Using a framework like React Native means the business and developer wants better performance.Continue reading on Medium »
- List of Top Local Databases used for React Native App Development in 2022!by MTCPE For You (Reactnative on Medium) on July 1, 2022 at 8:03 pm
This post enlists the prominent local databases to watch out for in 2022 if you are planning to develop an app with React NativeContinue reading on Medium »
- Can't upload RN app to TestFlight for ios, stuck on Ready to submit.by /u/antisocial104 (React Native - Building Native Mobile Apps w/JavaScript) on July 1, 2022 at 7:25 pm
Hi Everyone! I have archived my build on XCode, it appears on appstoreconnect, and currenltly on 'ready to Submit'. However, when i am trying to add External Group of testers, it comes back with an error: 'There was an error processing your request. Try again later'. But this error comes up for 2 days now, and i cannot do anything about it. Tried to delete groups and lots of other things, but nothing helps. Has anyone seen this before and knows how to fix it? Much appreciate your time! submitted by /u/antisocial104 [link] [comments]
- Programmer Browser | Open Source Browser for Developersby /u/Zestyclose_Fig_3805 (React – A JavaScript library for building user interfaces) on July 1, 2022 at 6:31 pm
submitted by /u/Zestyclose_Fig_3805 [link] [comments]
- body as root instead of divby /u/TheRNGuy (React – A JavaScript library for building user interfaces) on July 1, 2022 at 5:29 pm
By default there's div with id="root", but I changed it to body id="root" and no problems so far. I think it's unnecessary div. Or there could be problems with this approach? submitted by /u/TheRNGuy [link] [comments]
- expo-cli is giving - Error downloading and extracting template package: Error: Could not parse JSON returned from "npm pack expo-template-blank --dry-run" error while using expo init my-appby /u/Specialist_Access_54 (React Native - Building Native Mobile Apps w/JavaScript) on July 1, 2022 at 4:01 pm
I am new to react-native and went for expo-cli for creating application following a tutorial, but I am getiing this error while creating my first app. I am not aware how to solve this so can someone please help. This is the error I am getting- D:\projects\Applications\first-app>expo init first-app √ Choose a template: » blank a minimal app as clean as an empty canvas Error downloading and extracting template package: Error: Could not parse JSON returned from "npm pack expo-template-blank --dry-run". expo-template-blank-45.0.3.tgz Error: Unexpected token e in JSON at position 0 × Something went wrong while downloading and extracting the template. Can't read JSON file: D:\projects\Applications\first-app\first-app\app.json └─ Cause: Error: ENOENT: no such file or directory, open 'D:\projects\Applications\first-app\first-app\app.json' ├─ readAsync (C:\Users\Ahmad Affan\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\json-file\src\JsonFile.ts:158:13) ├─ extractAndPrepareTemplateAppAsync (C:\Users\Ahmad Affan\AppData\Roaming\npm\node_modules\expo-cli\src\commands\utils\extractTemplateAppAsync.ts:25:25) └─ actionAsync (C:\Users\Ahmad Affan\AppData\Roaming\npm\node_modules\expo-cli\src\commands\initAsync.ts:287:19) My node version is v16.15.1 npm version is 7.4.2 Expo version is 5.4.12 submitted by /u/Specialist_Access_54 [link] [comments]
- undefined is not an object (evaluating '_navigator.dispatch')by /u/hafi51 (React Native - Building Native Mobile Apps w/JavaScript) on July 1, 2022 at 3:50 pm
I'm trying to navigate to a certain screen when clicking on notification but i get above mentioned error. here is my MainApp.js import React, {useEffect, useState} from 'react'; import { View, Text, TextInput, TouchableOpacity, Modal, Image, Alert, } from 'react-native'; import {NavigationContainer, useNavigation} from '@react-navigation/native'; import {NavStack} from './src/RootNavigator/StackNavigation'; import {NavStack2} from './src/RootNavigator/MainNavigator'; import {useDispatch, useSelector} from 'react-redux'; import { navigate, setTopLevelNavigator, } from './src/RootNavigator/MainNavigator/NavigationService'; import {dispatchFunc, saveToken, checkPopUps} from './src/Redux/action'; import PopUpBox from './src/Component/PopUp'; import * as Animatable from 'react-native-animatable'; import FastImage from 'react-native-fast-image'; import {gold3} from './src/Colors'; import { heightPercentageToDP, widthPercentageToDP, } from 'react-native-responsive-screen'; import messaging from '@react-native-firebase/messaging'; import Strings from './src/Translation'; import NavigationService from './src/RootNavigator/MainNavigator/NavigationService'; import {navigationRef} from './RootNavigation'; export default function App(props) { const dispatch = useDispatch(); const login = useSelector(state => state.user.login); const language = useSelector(state => state.user.language); const [isAnimate, setAnimate] = useState(true); useEffect(() => { updateData(); }, []); useEffect(() => { if (language) { if (language === 'en') { Strings.setLanguage('en'); } else if (language === 'es') { Strings.setLanguage('es'); } } }, []); useEffect(() => { const unsubscribe = messaging().onNotificationOpenedApp( async remoteMessage => { console.log( 'A new FCM message arrived!', JSON.stringify(remoteMessage), ); }, ); return unsubscribe; }, []); const updateData = async () => { const authStatus = await messaging().requestPermission(); const enabled = authStatus === messaging.AuthorizationStatus.AUTHORIZED || authStatus === messaging.AuthorizationStatus.PROVISIONAL; if (enabled) { getFcmToken(); console.log('Authorization status:', authStatus); } messaging().onMessage(async remoteMessage => { console.log('remoteMessage', JSON.stringify(remoteMessage)); }); messaging().setBackgroundMessageHandler(async remoteMessage => { console.log( 'Message handled in the background!', JSON.stringify(remoteMessage), ); }); messaging().onNotificationOpenedApp(remoteMessage => { console.log( 'Notification caused app to open from background state:', JSON.stringify(remoteMessage), ); // Alert.alert('ap[iii', 'lolll'); Alert.alert('Alert Title', 'My Alert Msg'); NavigationService.navigate('MyBooking'); }); // Check whether an initial notification is available messaging() .getInitialNotification() .then(remoteMessage => { if (remoteMessage) { console.log( 'Notification caused app to open from quit state:', remoteMessage.data, ); } }); }; const getFcmToken = async () => { const fcmToken = await messaging().getToken(); if (fcmToken) { console.log('Your Firebase Token is:', fcmToken); dispatch(saveToken(fcmToken)); } else { console.log('Failed', 'No token received'); } }; return ( <NavigationContainer ref={navigationRef}> <PopUpBox okClick={() => dispatch(dispatchFunc())} /> {!login ? <NavStack /> : <NavStack2 />} {isAnimate && ( <Modal visible={isAnimate} animationType="none" transparent={true}> <FastImage source={require('./src/Images/splash.jpg')} resizeMode={FastImage.resizeMode.cover} style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}> <View style={{ width: widthPercentageToDP(100), flex: 0, alignItems: 'center', }}> <Animatable.Image source={require('./src/Images/Goldenlogo.png')} resizeMode={FastImage.resizeMode.contain} style={{ width: widthPercentageToDP(50), height: widthPercentageToDP(50), }} animation="slideOutDown" duration={3000} /> <View style={{height: heightPercentageToDP(27)}} /> <Animatable.Text style={{ fontSize: widthPercentageToDP(7), color: gold3, fontFamily: 'Montserrat-Bold', textAlign: 'center', marginTop: heightPercentageToDP(3), }} animation="slideOutUp" duration={3000}> {'MYHOOKAH'} </Animatable.Text> </View> </FastImage> </Modal> )} </NavigationContainer> ); } App.js import React from "react"; import { View } from "react-native"; import { Provider } from "react-redux"; import MAINAPP from "./MainApp"; import { Store, persistor } from "./src/Redux/store"; import { PersistGate } from "redux-persist/integration/react"; import SplashScreen from 'react-native-splash-screen' import RemotePushController from './src/Service/RemotePushController' export default class App extends React.Component { componentDidMount() { setTimeout(() => SplashScreen.hide() , 2000); } render() { return ( <View style={{ flex: 1 }}> <Provider store={Store}> <PersistGate loading={null} persistor={persistor}> <MAINAPP /> <RemotePushController /> </PersistGate> </Provider> </View> ); } } RootNavigation.js import React from 'react'; export const navigationRef = React.createRef(); const navigate = (name, params) => navigationRef.current?.navigate(name, params); export default { navigate, }; NavigationService.js import {NavigationActions} from 'react-navigation'; let _navigator; function setTopLevelNavigator(navigatorRef) { _navigator = navigatorRef; } function navigate(routeName, params) { _navigator.dispatch( NavigationActions.navigate({ routeName, params, }), ); } export default { navigate, setTopLevelNavigator, }; And if i update MainApp.js like this, then i get this error: The action 'Navigation/NAVIGATE' was not handled by any navigator. <NavigationContainer ref={navigatorRef => { NavigationService.setTopLevelNavigator(navigatorRef); }}> <PopUpBox okClick={() => dispatch(dispatchFunc())} /> {!login ? ( <NavStack ref={navigatorRef => { NavigationService.setTopLevelNavigator(navigatorRef); }} /> ) : ( <NavStack2 ref={navigatorRef => { NavigationService.setTopLevelNavigator(navigatorRef); }} /> )} ..... remaining code as it is.... submitted by /u/hafi51 [link] [comments]
- Question: Regarding when to provide restore purchases for in app purchaseby /u/Marquis_of_Carabas (React Native - Building Native Mobile Apps w/JavaScript) on July 1, 2022 at 3:26 pm
I'm working on a React Native project for iOS that has a lite and premium model for users. There are no subscriptions or consumables. I have a non-consumable called premium version for .99. I'm also using react-native-iap library in the app. If all have is a one time unlock for .99. So do I need to implement a restore purchases option for users? If so why? https://react-native-iap.dooboolab.com/docs/usage_instructions/restoring_purchases Thanks for your time! submitted by /u/Marquis_of_Carabas [link] [comments]
- Watermelon db withObservable forward refby /u/CharacterGrass8151 (React Native - Building Native Mobile Apps w/JavaScript) on July 1, 2022 at 3:24 pm
Im trying to optimize my app by making screens render on PagerView active page. I made active state, if state is active render page, else render null. Im changing state to true on swiping with forward ref and imperative handle. It's all working great on components without observables, but when i enhance components with withObservables, i cant forward ref through observable component even when i pass ref as a prop, not as a ref. submitted by /u/CharacterGrass8151 [link] [comments]
- datetimepicker not showing up on expo projectby /u/danilosilvadev (React Native - Building Native Mobile Apps w/JavaScript) on July 1, 2022 at 2:40 pm
Hey guys i just tried to use react-native-datetimepicker/datetimepicker in imperative mode as requested and the drawer still doesn't show. I am using expo and did the installation with it. Does someone have some idea how to handle this date picker? it didnt work on any mode i have tried until now ts DateTimePickerAndroid.open({ value: new Date(), onChange: () => {}, mode: 'date', is24Hour: true, }) submitted by /u/danilosilvadev [link] [comments]
- The React Native Avengers: GestureHandler, Reanimated, and Skiaby /u/wcandillon (React Native - Building Native Mobile Apps w/JavaScript) on July 1, 2022 at 2:38 pm
submitted by /u/wcandillon [link] [comments]
- Secure storage library?by /u/chkml (React Native - Building Native Mobile Apps w/JavaScript) on July 1, 2022 at 2:31 pm
We looking for secure storage library for ios and android to store simple strings like name, jwt.. Any recommendation? submitted by /u/chkml [link] [comments]
- Authentication and Authorization in ReactJSby /u/samjoshusa (React – A JavaScript library for building user interfaces) on July 1, 2022 at 1:10 pm
submitted by /u/samjoshusa [link] [comments]
- Authentication and Authorization in ReactJSby /u/samjoshusa (React Native - Building Native Mobile Apps w/JavaScript) on July 1, 2022 at 1:09 pm
submitted by /u/samjoshusa [link] [comments]
- [GUIDE] React Fetch Databy /u/ZestycloseChocolate (React – A JavaScript library for building user interfaces) on July 1, 2022 at 1:03 pm
submitted by /u/ZestycloseChocolate [link] [comments]
- FlatList onRefresh and onScroll conflictsby /u/SnooOpinions1120 (React Native - Building Native Mobile Apps w/JavaScript) on July 1, 2022 at 9:20 am
I use pullup my FlatList to refresh list item seems everything goes ok, but I already had a onScroll callback to watch scroll directions. when pullup the Flatlist from bottom to top to refresh (like refresh the twitter list), My callback of onScroll listen the event and I don't want when pullup the FlatList while the onscroll is still listen the event. submitted by /u/SnooOpinions1120 [link] [comments]
- Image handling in reactby /u/mr_162 (React – A JavaScript library for building user interfaces) on July 1, 2022 at 8:23 am
Hello React dev, I am currently working on Component (DocumentList) which shows list of documents (image of each document), when clicked on any image, it will show the document in pdf view(DocumentPdfView). I have a component for each document image (DocumentImageView) which calls the api to fetch document image (endpoint=/documentImages/{id}), and it's calling api every time DocumentImageView component is being rendered, and it looks slow sometimes, So is there any way to make it efficient? Like caching image or some ideas on similar line. submitted by /u/mr_162 [link] [comments]
- A native app that just contains webviews in order to have three.js.by /u/zeesh_0 (React Native - Building Native Mobile Apps w/JavaScript) on July 1, 2022 at 5:39 am
<WebViewsource={{ uri: 'https://houseof.maserati.com/en/' }}/> The react-native-webview lets one render a website on the native app. I wanted to make an application that uses three.js. Three.js has integrations with Expo, but the framework I am using is Solito(Expo + Next.js), I don't know why but using Three.js crashes the app. What I thought was to build a website using three.js and then embed it in the Webview component in React Native. So basically the Native app will just have webviews all around or otherwise I will have to mantain two different codebases. Is this possible, If yes, What are the problems I could face?I am trying to build an e-commerce website. Thank you for your time. submitted by /u/zeesh_0 [link] [comments]
- Authenticate user when visit webapp on an in-app browserby /u/Working_Oil_617 (React Native - Building Native Mobile Apps w/JavaScript) on July 1, 2022 at 4:01 am
Hello React Native friends 👋, I am currently updating an app (www.dopshop.com) built on React Native. I am facing an issue that I am sure has a simple solution. I am trying to allow users to update their subscription plan when they press on a certain View. That View would open up an in-app browser to an authenticated route. My question is, how can I properly authenticate the user when they hit the in-app browser from the mobile app? My best guess is to send a header with the access JWT token. I would really appreciate some guidance. Thank you! submitted by /u/Working_Oil_617 [link] [comments]
- Can't figure out what's the issue preventing me from integrating this drag-select library into a certain sandboxby /u/maxifederer (React – A JavaScript library for building user interfaces) on July 1, 2022 at 3:30 am
https://codesandbox.io/s/admiring-rgb-00lprb https://github.com/aurbano/react-ds I am trying to implement this drag-select feature, but for some reason I am getting some errors. I disabled the typing, but I still see some issue from the lack of typing and also it just won't render even if it compiles. const renderSelection = () => { if (!ref || !elRefs) { return null; } return ( <Selection target={ ref } elements={ elRefs } onSelectionChange={ handleSelection } style={ styles } /> ); } This is the most crucial part, but the working version without react-ds is below: https://codesandbox.io/s/womjln5lw submitted by /u/maxifederer [link] [comments]
- Is there a website with svg files we can use for free?by /u/maxifederer (React – A JavaScript library for building user interfaces) on June 30, 2022 at 10:15 pm
https://www.svgrepo.com/vectors/gears/ I saw this page, but I noticed that a lot of them are under CC0 license and I need to give attribution. I want to use it in a commercial application without the risk of being sued. submitted by /u/maxifederer [link] [comments]
- Where to put @media queries in React app?by /u/raulalexo99 (React – A JavaScript library for building user interfaces) on June 30, 2022 at 10:08 pm
Media queries usually involve several containers and components in the whole page. So, when you need a media query: Do you write a single media query rule on each of all the component who need it? Or do you place all media queries in a single file? Or do you have another strategy? submitted by /u/raulalexo99 [link] [comments]
- Flash List: Fast & Performant React Native List by Shopifyby /u/foocux (React Native - Building Native Mobile Apps w/JavaScript) on June 30, 2022 at 7:21 pm
The folks at Shopify released today FlashList, which is a faster alternative to FlatList with a similar API. More details here: https://shopify.github.io/flash-list/ submitted by /u/foocux [link] [comments]
- Udemy or Coursera ?by /u/Automatic-Advisor-46 (React – A JavaScript library for building user interfaces) on June 30, 2022 at 7:02 pm
submitted by /u/Automatic-Advisor-46 [link] [comments]
- Helper functions and functional components. Inside component or outside component?by /u/raulalexo99 (React – A JavaScript library for building user interfaces) on June 30, 2022 at 5:03 pm
In functional components, what's the difference between putting helper functions inside and putting them outside the component's body? submitted by /u/raulalexo99 [link] [comments]
- Any lib recommendation to handle code snippet rendering and highlighting with feedbacks?by /u/brubsabrubs (React – A JavaScript library for building user interfaces) on June 30, 2022 at 4:37 pm
I am making a code feedback platform that uses sonarqube's API to analyze and give feed on possible bugs, code smells and vulnerabilites. I have already finished the integration with the sonarqube API, so the next step is to implement a frontend for this feature. I was wondering if there are any library recommendations for rendering code snippets and highlighting specific pieces of the code. Maybe something similar to this: https://preview.redd.it/ml49wlolds891.png?width=331&format=png&auto=webp&s=fbe444c94c05cb0fe2f22daf6d23b9e29b534ea8 https://preview.redd.it/x98u72smds891.png?width=629&format=png&auto=webp&s=22034d45d46ace6c4ce61b04bfc9dff47e3dfe99 I can probably just make a component that does this myself, but if there are any famous libraries that do this for me it would save me a ton of time thanks in advance submitted by /u/brubsabrubs [link] [comments]
- Initializing Stateby /u/2014worldpogchamp (React – A JavaScript library for building user interfaces) on June 30, 2022 at 3:22 pm
Is this an “acceptable” way to set initial state values in React? (Inside a class component…): constructor(props){ super(props); this.state = { hours = this.findHours(); } } hours(){ const now = new Date(); return now.getHours(); } submitted by /u/2014worldpogchamp [link] [comments]
- How to connect MongoDB with ReactJS ?by /u/FarmingDev (React – A JavaScript library for building user interfaces) on June 30, 2022 at 1:32 pm
Hello fellow dev ! Sorry, my english is kinda awful. I have a small (big) problem that keep my project from working. My back work just fine, and I can't find any problems with my front either. I use MongoDB has my database and react for the front. My server and dataBase are working fine, there is no problem there. But my front doens't connect with my back. When I try to register or log in It doesn't work. I can't find any data in my database. I tried using Mern, but it still won't work. I'm suspecting that Redux is the one that keep blocking the connexion between Front and back, but I can't find any problem there either. Can you guys please help me find the cause of all this ? Here my repo if you wan't to look a little. Thanks ! submitted by /u/FarmingDev [link] [comments]
- React context for Minesweeper?by /u/Less-Simple-9847 (React – A JavaScript library for building user interfaces) on June 30, 2022 at 7:00 am
Hey folks, just looking to learn react context and want opinions on how good a design would it be yo use it for managing state of all cells in the game? Most of the blogs online try and do logic in class components with local state but I want to separate the logic in one single place. Thoughts?? submitted by /u/Less-Simple-9847 [link] [comments]
- Hello Members of r/Reactby /u/GennaroIsGod (React – A JavaScript library for building user interfaces) on January 15, 2021 at 7:58 pm
Theres a new mod in town https://preview.redd.it/xl5wie2exjb61.png?width=220&format=png&auto=webp&s=19367d879f21bf1bd3ef3c2825b8b3568f10b84e Seems as though this sub has gone a little bit without a mod and it seems like it's done pretty well for the most part. But since we're at this point are there any changes about the sub you'd like to see? Hope to interact with all of you 🙂 submitted by /u/GennaroIsGod [link] [comments]