What classifies a container in React Native? - react-native

I have started working with flex box on React native, on CSS you should set the display to flex but on RN, this is set by default.
What classifies a container object where you can set alignItems, justifyContent?
Does it only need to be a view? or is every single component a potential container?

In my experience objects that honour flex box are ones you would expect to such as View and ScrollView - whereas views like Text do not and are likened to display: inline-block or <span />.
In the example here, The View within the ScrollView honours it's parents flex properties, and similarly the Text inside the View. However the Text objects do not behave in the same way and if I'm not mistaken, would not appear to change when adjusting it's flex properties.

Container components are those React Native components which have access to the store. These components make API calls, do processing and contain the business logic of the app. Container components shouldn't have the view logic or presentational logic. The job of container components is to compute the values and pass them as props to the presentational components.
Difference between Presentational Components Container Components
Purpose How things look (markup, styles) How things work (data fetching, state updates)
Aware of Redux No Yes
To read data Read data from props Subscribe to Redux state
To change data Invoke callbacks from props Dispatch Redux actions
Are written By hand Usually generated by React Native Redux

Related

How to get states of multiple rendered component in react native?

I am developing a mobile app with react native. I have a component "Period" which has a couple of TextInputs, each TextInput is stored as state. This component gets rendered in a flatlist multiple times. Now I wonder how i can get the state values of each instance of "Period" that gets rendered in Flatlist?
Any Explanation how this works in React Native. I thought every component instance has its on states?
Thanks alot
I would suggest to put all your inputs states and onchange functions callbacks in the parent component containing the Flatlist, then you can pass your states as props to children components "Period"s.
I would suggest also working with a library such as Formik to handle dynamic forms with multiple inputs

Blazor: Detect when component is shown in the screen

Let's say I have a blazor component that uses a lot of resources to create an animation, it doesn't make sense to keep rendering it if the user scroll past the component (i.e. the component not visible in the screen). Is there a way to detect this using Blazor?
I am aware that I can rely on Intersection Observer API with JS, but I am looking for something in Blazor/C#.
Thanks,

How to update state of nested components when app receive notifications?

So in my app I have a main component which have switch navigator and then inside switch navigator I have a tab navigator which renders different screens. I have registered notification handler in top component.
Now the problem is that when notification is received, I want to make some changes on screens inside tab navigator.
I have read about redux which will provide common store so state could be updated but I dont want to use that.
I have also read about lifting state up but in my case i have more nested components so I dont want to do that as well.
So suggest me some way to do it?
I have solved the problem by using react context api. It is simple wrap your top level component with provider and define some veriable and access that variable in any component.

Ignore style cascading in React Native

Context:
I am using ReactNavigation to implement the navigation on my React Native app. All my views so far have no styles defined for them, and look just fine if I access them directly, without any routing. When accessed through the library's StackNavigator, however, they get extremely distorted, to the point where all components collapse into one. I suspect this is happening due to the cascading of the navigator's styling.
Question:
Is there any way to disable style cascading for a particular component in ReactNative?

How to implement an animated component with a fixed layout in react native

I would like to know how to implement a component that has a fixed layout, but frequently updates its display.
Suppose it is an element that needs to be tied to some in app state like a stop watch timer:
(source: mzstatic.com)
If the timer is running then the hundredths of seconds should be ticking on every frame. But in react native my instinct is to make that a <Text>00:12.36</Text> element.
Obviously calling render() is wrong. Is creating a native module the only option for this? Or is there some mechanism to drive frequent display changes within pure js? Are there best practices in this case?
Checkout setNativeProps it allows directly set text (and other properties of elements). Here're docs
You will be able to set text of <Text> component as
this._textInput.setNativeProps({text: '00:12:36'});