This question already has answers here:
ReactJS: what is the difference between functional component and class component
(11 answers)
Closed 2 years ago.
I started learning React Native some days ago, having never worked with it or even React.js before, and according to React Native Dev website, there seems to be two different approaches when it comes to React Native code writing. The issue is, as I learn reading several docs and watching tutorials, it gets a bit confusing to me at times, having to figure out which approach is used.
Is one of these approaches more recent than the other ?
Is there one I should favour at the expense of the other ?
I would say that the functional component approach is "newer" since there has been a lot of emphasis on using hooks as of late.
Personally, the ability to use hooks is a huge plus for me so I always look to use functional components if I can. I also find that I can do the same thing in a lot less code when I use functional components + hooks.
Related
What are the disadvantages of conditionally rendering <ApolloProvider> components?
Sorry if you feel like this is a noob question.
I just came across a project in React Native using GraphQL with ApolloClient. The server exposes multiple schemas, each with its own endpoint.
And so the client logic, was to conditionally render a <ApolloProvider> component with a different client as props.
Also the condition to choose which client to render depends on a React Context.
Example
Sounds like an antipattern to me.
Will the cache work as it should?
It is probably impossible to introspect the schema(s), and thus use a code generator for Graphql types/operations.
I thought I would present these "issues" so that we could make the best use of GraphQL. To take advantage of all its benefits and not just to bend to the choices made on the server side.
One way to improve would be to forget about these multiple endpoints, either by grouping them together or by creating a gateway that would do so.
So what do you think about it? It definitely seems like it brings a lot of painpoints?
Have you ever crossed a similar design? And was it painful to use?
Note for people before deleting my topic without even looking at it:
Of course, I've searched for similar topics on StackOverflow. I could only find one that isn't related to my problem: How to use react-native-webview-leaflet?
Hello everyone,
I'm kind of new to React Native (only got to learn navigators and basic components such as Text, View, FlatList, getting my data from my own API, etc) and I didn't learn to React at all as a first step.
Today, I'm a student in a kind of school collaborating with some big science research center linked to my government and I have to make a map app for them. They have one non-negotiable criterion that the project must not use any of Google technology in it. I would like to use Leaflet inside React Native because it allows me a lot of customization about map markers and animations I will need to use.
After spending hours searching for some tutorials, the "biggest" thing I've found is this on Github: https://github.com/reggie3/react-native-webview-leaflet and this person even made a video example of a working project with Leaflet inside React-Native: https://www.youtube.com/watch?v=IurE-a9P3tY. Despite it being exactly what I'm looking for, I'm 100% confused about how to use it in terms of code (I'm not even able to display the basic background map) and I can't find any real help in form of a tutorial.
Would any people know something about it? I would be so grateful to you.
Thanks a lot and if you don't know about it, at least thanks for spending time to read.
) I am coding a really big vue app and now I have a question, how to organise importing mixins, filters and directives. I am in trouble because I see that I don't understant how to do it((( I hope somebody coud help me.
How to organise...
it depends...
are you working with a team or alone?
Do you want to move fast or keep your app maintainable?
Does your app have a user base (critical) or is it a side project?
The first question I would ask is what code is duplicated and can be simplified or generalized.
The goal is to shrink the code as much as possible while staying clean. Remember that in six months you will want to read your changes and immediately know what is going on.
If you are using Vue 2, I would ask the question, why are you using filters?
It is one of the breaking changes when it comes to migrating to Vue 3. Think of another solution, like methods or computed properties (easily implemented).
This question cannot be answered here. It is too opinion based. There are many cases to consider and everyone has their own preference. Some like code splitting, some like to collect a lot in one file. Some a mixture, depending on how important or often functions are used.
Sorry.
I am new to React Native and only recently picked it up, I am using it to make an app for my final year university project, learning the framework as I go using different examples from online.
So far I have been using function components with everything for one component in the same class, eg. view, functions and styles. - So far this has been working and seems to preform efficiently.
My question is aimed at any experienced React Native developers. - Is my current approach of function components a good coding practice for React Native apps or should I be using class components. From my little experience it seems function components are easier and I have done some research that shows function components are becoming more common with hooks etc. - I'm just not sure if its the best approach for a full application.
Another question I have is aimed at design patterns. - Should functionality, view and styles all be in the same class or would it be better practice to split them out and just import as appropriate - similar to Angular. The reason i ask this is because all examples that I have seen/followed up to now take the approach of everything in the same class but that may just be for presentation purposes.
How do you handle communication between components with no common parent in react-native ?
What's the best way to communicate between two unrelated components ?
I did some research and the most recommended way seems to be using context https://reactjs.org/docs/context.html.
There are multiples way to handle a global state, one of them is the new React Context API, but one of the most famous is redux, written by Dan Abramov, who works at Facebook, inspired by flux, an old facebook library to manage global state. There is also Mobx and many others, I suggest you take a look at each one and see what fits you best, it's hard to tell you without knowing your problem. Feel free to ask any other question about one of them