react-native-threads | Create new JS processes for CPU intensive work | Architecture library
kandi X-RAY | react-native-threads Summary
kandi X-RAY | react-native-threads Summary
Create new JS processes for CPU intensive work
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Starts a web thread
- Builds a react application context
- Creates a bundle loader for local development
- Download thread script to file
- This method is invoked when the VM is destroyed
- Called when a host is destroyed
- Terminates the react context
- Handles a host resume
- Called when host resume is suspended
- Handles a host pause
- On host pause
- Initialize
- Loads the Flipper
- Posts a message to a thread
- Sends a message to the thread
- Create native modules
- Create view managers
- Stops a thread
- Post a data message to the device
- Create native modules
react-native-threads Key Features
react-native-threads Examples and Code Snippets
Community Discussions
Trending Discussions on react-native-threads
QUESTION
I have a react native application. There are 2 components: tickets and ticket details. In the "tickets" component there is a list of tickets. When a user clicks on a single ticket the "ticket details" component is shown. In the "tickets" component there is the setInterval which retrieves tickets from the server every 10 seconds. In the "ticket details" component there is the animated progress bar(using react native Animated module).
Issue: every 10 seconds animation in "ticket details" component freezes. How to solve?
I guess that is because of setInterval
blocks main UI thread.
I tried: - https://facebook.github.io/react-native/docs/interactionmanager.html but I didn't even manage to call runAfterInteractions on my RN 0.58.
The next thing that comes to mind is https://github.com/joltup/react-native-threads. But it is a native module with some scary issues like "memory leak" and additional build instructions so I don't really want to use it.
I think I miss a way easier method to solve this issue.
This is how I get tickets in the "tickets" component. getTickets is a redux action.
...ANSWER
Answered 2019-Jul-29 at 23:48The animation was blocked because it was running in JS thread instead of UI thread.
You should run animation in the UI thread via https://facebook.github.io/react-native/docs/animated with option useNativeDriver: true. With this option animation is smooth.
Also notice that if you use PanResponder + Animated then useNativeDriver option does not work. You can go with https://github.com/wix/react-native-interactable. I've tried it and all animations on touches are running in the UI thread so animation is not blocked.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install react-native-threads
In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name]
Go to node_modules ➜ react-native-threads and add RNThread.xcodeproj
In XCode, in the project navigator, select your project. Add libRNThread.a to your project's Build Phases ➜ Link Binary With Libraries
Run your project (Cmd+R)<
Open up android/app/src/main/java/[...]/MainApplication.java
Add import com.reactlibrary.RNThreadPackage; to the imports at the top of the file
Add new RNThreadPackage(mReactNativeHost) to the list returned by the getPackages() method
Also note that only the official react native modules are available from your threads (vibration, fetch, etc...). To include additional native modules in your threads, pass them into the RNThreadPackage constructor after the mReactNativeHost like this: new RNThreadPackage(mReactNativeHost, new ExampleNativePackage(), new SQLitePackage())
Append the following lines to android/settings.gradle: include ':react-native-threads' project(':react-native-threads').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-threads/android')
Insert the following lines inside the dependencies block in android/app/build.gradle: compile project(':react-native-threads')
In Visual Studio add the RNThread.sln in node_modules/react-native-threads/windows/RNThread.sln folder to their solution, reference from their app.
Open up your MainPage.cs app
Add using Thread.RNThread; to the usings at the top of the file
Add new RNThreadPackage() to the List<IReactPackage> returned by the Packages method
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page