<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Lauren Steven on Medium]]></title>
        <description><![CDATA[Stories by Lauren Steven on Medium]]></description>
        <link>https://medium.com/@laurenmontenegro10?source=rss-36ebadac0d71------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*V_UruZGOCHr1yovQcz9H0w.jpeg</url>
            <title>Stories by Lauren Steven on Medium</title>
            <link>https://medium.com/@laurenmontenegro10?source=rss-36ebadac0d71------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 03:40:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@laurenmontenegro10/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Cómo construir y publicar aplicaciones con Expo Application Services]]></title>
            <link>https://medium.com/nicasource/c%C3%B3mo-construir-y-publicar-aplicaciones-con-expo-application-services-ea2c8de9b530?source=rss-36ebadac0d71------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea2c8de9b530</guid>
            <dc:creator><![CDATA[Lauren Steven]]></dc:creator>
            <pubDate>Fri, 28 Oct 2022 12:02:19 GMT</pubDate>
            <atom:updated>2022-10-28T12:02:19.195Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LKprWTsEt1w0isLDvJqmMQ.png" /></figure><p>EAS es el acrónimo de Expo Application Services, este es un servicio en la nube que provee una forma fácil y rápida de llevar su aplicación Expo o React Native desde el desarrollo hasta las tiendas de aplicaciones. <br>Expo ofrece este servicio a través de 3 planes, uno gratuito y 2 de pago. Puedes encontrar más detalles sobre las diferencias entre los mismos en este enlace <a href="https://expo.dev/pricing">https://expo.dev/pricing</a>.</p><p>Por otra parte, EAS cuenta con 2 características principales:</p><ul><li>EAS Build: para construir las aplicaciones, tanto para iOS como Android.</li><li>EAS submit: para enviar las apps construidas hacia las tiendas de aplicaciones.</li></ul><p>En este artículo me centraré en mostrarte cómo se realiza el proceso para iOS, sin embargo los pasos para hacerlo para Android no varían demasiado.</p><h3>Creando nuestro primer build</h3><p>Antes de que empecemos a utilizar EAS debemos tener una cuenta de Expo. Si aún no la tienes visita <a href="https://expo.dev/signup">https://expo.dev/signup</a> y crea una.</p><p>Asimismo, es bueno que conozcas un par de limitaciones del servicio. Actualmente, el soporte para proyectos <strong>Managed Expo</strong> solo está disponible para SDK 41 y superior. Por otra parte, debes tener en cuenta que los builds que tarden más de 2 horas en ejecutarse, se cancelarán.</p><h4>Instalación</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9K7GvTFmGib7d2jzBbP4Fg.png" /></figure><p>Para poder interactuar con los servicios en la nube de EAS desde nuestra máquina local, debemos hacer uso de EAS CLI. Ejecuta el siguiente comando para instalarlo de forma global:</p><p>npm install -g eas-cli</p><p>Adicionalmente, debes iniciar sesión en tu cuenta de Expo. Ejecuta eas login e ingresa las credenciales. Deberías ver lo siguiente en la terminal:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*OkihQP8rNR5Hiffz1rhKpg.png" /></figure><p>Si ingresaste tu email o password de forma incorrecta recibirás el siguiente error: Your username, email, or password was incorrect.De lo contrario, ejecuta eas whoami y deberías ver tu username en la terminal.</p><h4>Configuración</h4><p>Para configurar tu proyecto iOS y/o Android y que sea compatible con EAS Build debes ejecutar el siguiente comando desde el directorio de tu proyecto:</p><p>eas build:configure</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dzBt_LLLbJ-5ECQpDAftiQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*82l75IE1fAhvwrjgzGlHgQ.png" /></figure><p>Una vez elijas una plataforma, el cligenerará el archivo eas.json con lo siguiente:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8PfncPzGPMpemLv0IjqkGg.png" /></figure><h3>Build</h3><p>Luego de realizar la instalación y configuración de EAS en nuestro proyecto estamos listos para hacer build para iOS.</p><p>Sin embargo, antes de iniciar el build para las tiendas de aplicaciones, debes tener una cuenta de desarrollador de la tienda y generar o proporcionar credenciales para firmar las aplicaciones.</p><p>Si tu objetivo es crear aplicaciones para App Store, necesitas acceso a una cuenta con una membresía del Programa de desarrolladores de Apple. Puedes encontrar más información el siguiente enlace: <a href="https://developer.apple.com/programs">Apple Developer Program</a></p><p>Para iniciar con el build ejecuta el siguiente comando:</p><p>eas build --platform ios</p><p>Como en todos los pasos previos, eas cli te mostrará algunas preguntas con respuesta sugeridas que puedes seleccionar presionando enter.</p><p>Asimismo, te pedirá que inicies sesión con tu cuenta de Apple Developer y si tienes activado Two-factor Authentication te pedirá que ingreses el código enviado al dispositivo asociado a tu cuenta.</p><h4>Configurar credenciales</h4><p>Si alguna vez has tenido que publicar una aplicación en App Store, sabrás que es necesario crear crear las credenciales de iOS (distribution certificate, provisioning profile, y push notifications key) de forma manual la primera vez y que, incluso, puede llegar a ser un quebradero de cabeza.</p><p>En consecuencia, se te pedirá que generes credenciales si aún no lo has hecho. EAS es genial en este sentido, ya que ofrece una forma de generar estas la primera vez, solo debes responder a las preguntas Generate a new Apple Distribution Certificate? Y/n, Would you like to set up Push Notifications for your project? Y/n.</p><p>Una vez creados, estos se almacenarán en los servidores EAS y en builds posteriores se reutilizarán a menos que se especifique lo contrario.</p><p>Ahora bien, probablemente te estás preguntando cuan seguro es almacenar estas credenciales en los servidores de Expo. La mayoría de los datos almacenados por los servidores de Expo (credenciales o de otro tipo) están encriptados en Google Cloud, las credenciales solo están sin cifrar mientras se usan en memoria cuando se genera un nuevo build o se envían push notifications.</p><p>Si aún así no te convence, siempre tienes la opción de crear las credenciales de forma manual desde <a href="https://developer.apple.com/account/resources/certificates/list">Apple Developer Portal</a>, descargarlas y moverlas a un directorio apropiado y apuntar a ellas desde el archivo credentials.json en el directorio raíz de tu proyecto.</p><p>Continuando con el proceso y habiendo generado los certificados, tu proyecto se subirá a los servidores de EAS y posteriormente te mostrará una URL desde donde puedes ver el estado del build si es que deseas cerrar la terminal. Es bueno que sepas que si usas el plan gratuito, en dependencia de la hora a la que hagas el build puede tomar mayor o menor tiempo.</p><h3>Enviar la aplicación a App Store</h3><p>Una vez finalizado nuestro build, estamos listos para enviarlo a App Store Connect. Para hacer esto ejecuta el comando:<br>eas submit --platform ios</p><p>Deberías de ver lo siguiente en tu terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2UZYqW1uPkvw41NzJgXz0A.png" /></figure><p>Selecciona la primera opción para ver la lista de build creados, con información asociada (versión, número de build, hora de finalización).</p><p>Cuando lo selecciones, el siguiente paso es proveer, o un App Store Connect API Key (el API de App Store Connect requiere un JSON Web Token para autorizar cada request que haces) o un App Specific Password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-T-z6z2NJFA81Opp6I8rpA.png" /></figure><p>Puedes generar un token desde App Store Connect o crear un App Specific Password desde este sitio <a href="https://appleid.apple.com/">https://appleid.apple.com</a> y luego pegarlo en la terminal según corresponda y presionar enter para enviarlo.</p><p>Al finalizar, debería mostrarte el siguiente mensaje:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*QxPknKB4vVzuwVUA4ELppw.png" /></figure><h3>Automatizando el proceso</h3><p>Hasta ahora hemos visto cómo realizar este proceso de forma manual, sin embargo luego de un par de veces de construir y enviar las aplicaciones desde tu máquina se vuelve una pérdida de tiempo.</p><p>Por consiguiente, Expo creó un GitHub action para automatizar este proceso directamente desde el repositorio de tu proyecto en GitHub.</p><h4>Crear un workflow</h4><p>Para automatizar el proceso de creación vamos a proceder a crear el archivo de configuración de nuestro workflow. Primero debemos crear el directorio que lo contendrá y que obligatoriamente debe llamarse <em>.github/workflows/</em>.</p><p>Dentro de esta crearemos el archivo <em>ios-build.yaml </em>(Github Actions utiliza la sintaxis de <a href="https://yaml.org/">YAML</a> para especificar la configuración de todo el workflow) y agregamos el contenido siguiente:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hmhxfBJn2HIbheXkKUi-Rw.png" /></figure><p>Básicamente lo que indicamos en nuestro workflow es lo siguiente:</p><p><strong>on</strong>: especifica el evento que automáticamente ejecutará nuestro workflow. En nuestro caso, lo ejecuta cuando se realiza un <strong>push </strong>o<strong> merge </strong>sobre el branch <strong>main.<br>jobs:</strong> es el conjunto de pasos que se ejecutaran en nuestro workflow.<br><strong>steps</strong>: acá especificamos las tareas individuales que se llevarán a cabo.</p><ul><li>Setup repo:<strong>actions/checkout@v2 </strong>prepara el repositorio y lo descarga en nuestra instanci apara ejecutar el resto de acciones sobre el mismo.</li><li>Setup Node:<strong> actions/setup-node@v2 </strong>establece la versión de node y mantiene en cache las dependencias de nuestro proyecto</li><li>Setup Expo and EAS:<strong> expo/expo-github-action@v7</strong> permite instalar Expo CLI y EAS CLI.</li><li>Build and submit: acá utilizamos el comando para construir la aplicación y agregamos --auto-submit para enviarlo de forma automática después de que el build esté completo. Asimismo, agregamos los valoresEXPO_APPLE_ID y EXPO_APP_SPECIFIC_PASSSWORD a través de github secrets que son requeridos por EAS para enviar la app a App Store Connect.</li></ul><h3>Conclusión</h3><p>En resumen, hemos estudiado en detalle la configuración necesaria para que puedas construir y publicar tus aplicaciones fácil y rápido utilizando EAS, también las consideraciones de seguridad que debes tener al usar el servicio. Adicionalmente, hemos realizado la configuración de GitHub actions para realizar todo el proceso de forma automática en cada pull request.</p><p>Espero que este artículo te haya sido de utilidad. Si tienes alguna duda o comentario, no dudes en dejarlo en la sección correspondiente; estaré encantado de responder.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea2c8de9b530" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nicasource/c%C3%B3mo-construir-y-publicar-aplicaciones-con-expo-application-services-ea2c8de9b530">Cómo construir y publicar aplicaciones con Expo Application Services</a> was originally published in <a href="https://medium.com/nicasource">NicaSource</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to test React Native applications]]></title>
            <link>https://medium.com/nicasource/how-to-test-react-native-applications-56da81c2793e?source=rss-36ebadac0d71------2</link>
            <guid isPermaLink="false">https://medium.com/p/56da81c2793e</guid>
            <dc:creator><![CDATA[Lauren Steven]]></dc:creator>
            <pubDate>Mon, 19 Sep 2022 18:00:14 GMT</pubDate>
            <atom:updated>2022-09-19T18:00:14.923Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G_yLWLLfZYuA_beb9eTRiQ.png" /></figure><p>As your codebase grows, issues and bugs might appear. Errors in your application can lead to a bad user experience, business losses, and, ultimately, stress developers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*PfaQw2v7a2DBfMadwAiQbQ.gif" /></figure><p>To prevent chaos, testing your code before releasing it is crucial, and I’ll teach you the foundations to test your apps.</p><h3>What is testing?</h3><p>Testing is the process of evaluating and confirming that a software application does what it’s supposed to do in different scenarios. The goal is to have information about the quality of your application at any moment while you’re building it.</p><h4>The testing pyramid</h4><p>In 2012, Martin Fowler introduced the concept of the test pyramid. The metaphor explains a way of thinking that to create a balanced portfolio; we should use different automated tests. The main takeaway of the concept is that you should have many more low-level UnitTests than high-level BroadStackTests running through a GUI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pql81s2rhm6e3g9fGIE5RQ.png" /></figure><p>As seen in the image above, the three testing categories are:</p><ul><li>Unit tests</li><li>Integration tests</li><li>End-to-end tests</li></ul><p>We’ll implement the first two types on a React Native app in the following examples.</p><h3>React Native Testing Library</h3><p>The React Native Test Library (RNTL) is the best solution for testing React Native components as it uses the best testing practices. RNTL encourages you to test your application by avoiding the implementation details. The previous avoids refactors breaking your tests (false negatives) or your tests passing when you break your code (false positives). Also, the test style is very close to how the users would use your application.</p><h3>Installation<a href="https://callstack.github.io/react-native-testing-library/docs/getting-started#installation">​</a></h3><p>You will need to add Jest to your project. Jest is a JavaScript library that allows us to create, structure, and run tests. To do so, in your project’s folder, run:</p><p>yarn add — dev @testing-library/react-native @testing-library/jest-native react-test-renderer<a href="https://callstack.github.io/react-native-testing-library/docs/getting-started#using-yarn">​</a></p><p>The @testing-library/jest-native in the command above gives us additional React Native-specific jest matchers. Now that you have installed the libraries, go to your Jest configuration (jest.config.js) file and add this:</p><pre>{<br>  &quot;preset&quot;: &quot;react-native&quot;,<br>  &quot;setupFilesAfterEnv&quot;: [&quot;@testing-library/jest-native/extend-expect&quot;]<br>}</pre><p>And add the test script in the package.json</p><pre>&quot;scripts&quot;: {<br>  ...<br>  &quot;test&quot;: &quot;jest&quot;,<br>},</pre><h3>Our first test</h3><p>Suppose you have the typical counter component and want to test its behavior.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/08c8d882fcb7dbb3e78db540a8c9b454/href">https://medium.com/media/08c8d882fcb7dbb3e78db540a8c9b454/href</a></iframe><p>As shown in the above code, you have a &lt;Counter /&gt; component (line 4) with two buttons, one for increasing the counter (line 10) and the other for decreasing it (line 11). You also have a &lt;Text&gt; component (line 9) that shows the counter’s value.</p><p>If you want to test this component, RNTL gives some methods to render it, fire events, and get elements that may exist in your component.</p><p>Let’s see the first test:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/50948f0ec422c0ebfb5dd07a4f25bebc/href">https://medium.com/media/50948f0ec422c0ebfb5dd07a4f25bebc/href</a></iframe><p>First, you’ll need to define your test using the test function provided by jest. Then, in the first line of your test (line 8), you must use the render utility to render your component. Once your component is rendered, you can query some elements.</p><p>For this test, I’m using the getBy* query, which returns the first matching node if it exists. Otherwise, it throws an error. As you can see in line 9, the first expectation is to verify if the default counter value has the 0 value.</p><p>After it, you have to fire an event. The fireEvent.press invokes the press event handler on the element or parent element in the tree. In this case, line 12 will “press” the <strong>Increase </strong>button, passing the button’s reference to the press function.</p><p>Once you press that, the counter text should increase. Thus, in line 15, we verify that the counter text is now “1”.</p><p>Now, if you run the yarn test command, you will see that our test passed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*3D-uhZvMW0au87gRveCCAA.png" /></figure><p>As I mentioned at the beginning of the article, RNTL encourages you to test your application by avoiding implementation details. So, for example, if you refactor your code and rename the count and setCount the test still works as it should because your test is not coupled to your logic.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/444976fdf12299cd702f7a17b7bfbb2e/href">https://medium.com/media/444976fdf12299cd702f7a17b7bfbb2e/href</a></iframe><p>You can find more information <a href="https://kentcdodds.com/blog/common-testing-mistakes">here</a> if you want to read more details about testing implementation.</p><h3>Testing an Error Boundary</h3><p>According to the official React documentation:</p><blockquote>Error boundaries are React components that <strong>catch JavaScript errors anywhere in their child component tree, log those errors, and display a fallback UI</strong> instead of the component tree that crashed. Error boundaries catch errors during rendering, in lifecycle methods, and in constructors of the whole tree below them.</blockquote><p>In our next component, you have an error boundary class component. The only way we have to create error boundaries is by using Classes. You can read more information <a href="https://reactjs.org/docs/error-boundaries.html#introducing-error-boundaries">here</a>. It uses the children prop to render whatever you want to pass a child (wrap any part of your app with the error boundary) when there are no errors.</p><p>But, when there’s an unhandled error, the ErrorBoundary will render a fallback UI with information and one action to restore the app’s state and render the children prop again.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8e4d4664bdb545eeb99becb3f2678796/href">https://medium.com/media/8e4d4664bdb545eeb99becb3f2678796/href</a></iframe><p>Then if you want to wrap either a component or the whole app, you can use:</p><pre>&lt;ErrorBoundary&gt;<br>  &lt;MyApp /&gt;<br>&lt;/ErrorBoundary&gt;</pre><h4>Let’s see how to test this:</h4><p>First, you will create a component that allows us to simulate the error. Then, you need to verify that the component renders its children correctly when there are no errors. I’ll call the component “Bomb,” and it will receive the shouldThrow boolean prop to throw the error.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3e8dae8d1ab83e623e17ef22c0b60c01/href">https://medium.com/media/3e8dae8d1ab83e623e17ef22c0b60c01/href</a></iframe><p>The next test case should render the component and then re-render it with the error. To simulate the error, the prop shouldThrow is used in the re-render.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7d696d827db08f5085937c4aa08dcec6/href">https://medium.com/media/7d696d827db08f5085937c4aa08dcec6/href</a></iframe><h3>Final Thoughts</h3><p>Well, we have come to the end of the article, and we have covered the React Native Testing Library’s main functions and a couple of examples to understand how to test components. In future articles, I will focus on more realistic cases, such as navigation between screens and integration with redux or API calls. See you then!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56da81c2793e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nicasource/how-to-test-react-native-applications-56da81c2793e">How to test React Native applications</a> was originally published in <a href="https://medium.com/nicasource">NicaSource</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to fetch data in React Native using Apollo Client]]></title>
            <link>https://medium.com/nicasource/how-to-fetch-data-in-react-native-using-apollo-client-d9df8cc78463?source=rss-36ebadac0d71------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9df8cc78463</guid>
            <category><![CDATA[apollo-client]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Lauren Steven]]></dc:creator>
            <pubDate>Thu, 25 Aug 2022 21:00:25 GMT</pubDate>
            <atom:updated>2022-08-25T21:00:25.608Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*os1kjkApyOnLQXu7AVVtGw.png" /></figure><p>According to the official documentation, Apollo Client is a state management library for JavaScript that allows you to manage remote and local data with GraphQL. Apollo provides integration with React, making it easy to get or modify data in a GraphQL API using hooks.</p><p>In this article, I will focus on:</p><ul><li>Explaining the minimum configuration necessary to establish the connection with the public API GraphQL Jobs</li><li>How to use React hooks to get data.</li></ul><h3>Building our React Native Project:</h3><p>Before starting with our project, ensure you have installed expo-cli because we will use the expo for this guide. You can get more information about the tool here: <a href="https://docs.expo.dev/workflow/expo-cli/">expo-cli</a></p><p>The first thing we must do is create a new React Native project with expo-cli.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5dfa1325959b3544091aa50843dba3a5/href">https://medium.com/media/5dfa1325959b3544091aa50843dba3a5/href</a></iframe><p>Once the command execution has finished, a folder containing our project files will have been created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*L2o5mmHWeXzbzDEN" /></figure><p>To run your project, navigate to the directory: cd apollo-client-intro and use one of the following commands: yarn android or yarn ios</p><p>Now, we are ready to install dependencies. In this scenario, I’ll be using yarn, but if you prefer npm it’s ok. With Yarn, execute: yarn add @apollo/client graphql</p><p>The @apollo/client package includes features like in-memory caching, local state management, error handling, and React integration and we will be using it in React Native to fetch data from GraphQL Jobs API. The graphql package, for its part, contains the logic to parse our queries and mutations.</p><h3>Configure the GraphQL Client</h3><p>Before starting to consume the data, it is necessary to create an instance of the apollo client package to indicate: (1) which API we will point to, (2) how errors will be handled, (3) how requests should be made to the endpoints that require authorization, and (4) any other action that depends on the characteristics of our application.</p><p>In our case, we will only focus on the basic configuration, which is the definition of the API that we will consume. So, for it, we will create the client.js file and instantiate ApolloClient specifying in the URI property the URL of the GraphQL endpoint.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f8199fac601c05ae35a77aeedf4f99b/href">https://medium.com/media/7f8199fac601c05ae35a77aeedf4f99b/href</a></iframe><p>Once the configuration is ready, the easiest and fastest way to obtain data would be by calling the query method of the client object and passing it the necessary arguments; however, we will do it differently. We will expose the apollo instance globally so that any component or custom hook in charge of obtaining or modifying data can easily use it.</p><p>To make this easy, Apollo supplies us with the ApolloProvider component, which is similar to React’s Context Provider. The ApolloProvider wraps child components and makes the previously created instance accessible to those child components. Now, in our App.jsx, wrap the app with the ApolloProvider and pass the client prop.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cc137dd160cc8ba2aea79135104de202/href">https://medium.com/media/cc137dd160cc8ba2aea79135104de202/href</a></iframe><p>As you can see, there’s a &lt;JobList /&gt; component that we’ll create later.</p><h3>Fetching data</h3><p>To obtain or modify data, we can use one of the following hooks: useQuery, useLazyQuery, useMutation, and useSubscription. In this article, we will be using useQuery, which is used to get data and will allow us to obtain a list of jobs from the API.</p><p>To utilize the useQuery hook, we need to define the query in a string and wrap it in the gql function to pass it as the first argument to the hook (in our case, we only have one argument).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/62caf92b43ea9f2bd50be1e1588ab2af/href">https://medium.com/media/62caf92b43ea9f2bd50be1e1588ab2af/href</a></iframe><p>Now, we’re going to create the JobList component</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e05beba634bfd0c18cc5b8967c2ba514/href">https://medium.com/media/e05beba634bfd0c18cc5b8967c2ba514/href</a></iframe><p>The code above executes the query when React mounts the component and returns three state properties:</p><blockquote><em>loading</em>: when its value is true, the request is in progress.<br><em>error</em>: if it is different from null, it means that an error occurred and therefore it contains an object with information about it.<br><em>data</em>: it is an object that contains the data that we request in the query.</blockquote><p>Based on these properties we render different components depending on the state emitted by useQuery. Now if you run your app you should see the Loading component, and then the list of jobs</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*lWmo1CuhoP7Bjhiqz3eolg.png" /></figure><h3>Conclusion</h3><p>Well, this is the end of this introductory article. I hope it is a good starting point to begin your journey using Apollo Client. Feel free to leave your questions, suggestions, or contributions in the comments. Also, if you are interested in my content or want to talk about React Native or GraphQL, here are my social networks:</p><p>GitHub: <a href="https://github.com/LaurenceM10">https://github.com/LaurenceM10</a><br>Twitter: <a href="https://twitter.com/LaurenceM10_">https://twitter.com/LaurenceM10_</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9df8cc78463" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nicasource/how-to-fetch-data-in-react-native-using-apollo-client-d9df8cc78463">How to fetch data in React Native using Apollo Client</a> was originally published in <a href="https://medium.com/nicasource">NicaSource</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>