<?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 Ömer Reşithan Sonsuz on Medium]]></title>
        <description><![CDATA[Stories by Ömer Reşithan Sonsuz on Medium]]></description>
        <link>https://medium.com/@omersnsz?source=rss-df0d72cd7984------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*vMnwlLZezYj-vLb4.jpg</url>
            <title>Stories by Ömer Reşithan Sonsuz on Medium</title>
            <link>https://medium.com/@omersnsz?source=rss-df0d72cd7984------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 21:18:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@omersnsz/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[Which Is Better Context Api or Props?]]></title>
            <link>https://medium.com/@omersnsz/which-is-better-context-api-or-props-ad35dd1863e6?source=rss-df0d72cd7984------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad35dd1863e6</guid>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[context-api]]></category>
            <category><![CDATA[props]]></category>
            <dc:creator><![CDATA[Ömer Reşithan Sonsuz]]></dc:creator>
            <pubDate>Mon, 18 Apr 2022 23:36:56 GMT</pubDate>
            <atom:updated>2022-04-19T10:01:32.976Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_srwaYvMzR4jVgLTG5c5xg.png" /></figure><p>Use props instead of context API in components.I can hear you asking why I should use it.</p><p>Let’s start then.</p><p>First of all, let’s remember what Context Api and Props do.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3eVF1C1dIPx9LzrmhJ13MA.png" /></figure><p><strong>What is the context?</strong></p><p>Context is universal centralized data for your application. It allows us to pass data and methods to the Components.</p><blockquote>Positive:</blockquote><p>If you are using props and you need to pass data between multiple Nested Components to the last Child component. Data needs to be passed through each component in the tree using props. So every component needs to know this props data, even if it doesn’t use it.</p><p>Context This solves the problem. You can set the context at the top and all components in the middle don’t need to know anything about it and those at the bottom can access it. It fulfills the same need as Redux.</p><blockquote>Negative:</blockquote><p>Context makes debugging difficult, as it’s hard to find out what’s causing the error when you can’t see the data in subcomponents that don’t import Context. Even when you look at the Application Component and you know that there is a problem with one of the properties of the situation, but you have to look at all the components that are consuming it to understand which one is causing the problem. Use context only when necessary.</p><p>If you want to know more, click <a href="https://medium.com/@omersnsz/what-is-the-context-api-8ca19608bd5c">here</a>.</p><p><strong>What is the Props?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*RPofJfGqw0824eYCGxNkbw.png" /></figure><p>React is a library that helps us break down the UI into small reusable parts that we call components. We use Props to pass data between components. The data is passed to the component with the help of props.<br>So accessories help us to transfer data from one component to another.<br>Props work as Key-Value.<br>Data in accessories is now read-only, meaning it cannot be modified by the child consuming the data. So it is a one-way flow. (one way from parent to child). However, we can pass data from child to parent by taking advantage of the pass function via props.</p><p>If you want to know more, click <a href="https://medium.com/@omersnsz/what-do-props-and-state-do-in-react-da74ddf92911">here</a>.</p><p><em>Ok, now I think we have some idea about props and context api. Now let’s come to our topic.<br>Let’s consider why props should be used instead of context api.</em></p><blockquote>Let me ask you a question:</blockquote><p>Why do we use Context API in ReactJs?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kn4YcVvQkQ2l21M02nOYvg.png" /></figure><p>For example, to pass data from componentX to componentY (componentX, componentY, componentZ, componentQ…)</p><p>We have 4 components like Pass Props from componentQ and componentY to componentZ in componentX. Then why do we use the context API?</p><blockquote>Answer:</blockquote><p>From a code organization perspective, this only works if it makes sense that componentX directly manages componentQ. Often, this is not the case.</p><p>For example, let’s say componentX is the whole application component, and componentY is the header, and componentZ is a menu in the header, and componentQ is a menu item.</p><p>It doesn’t make sense for the top component to import every single little component that needs the top component’s state; the top component would quickly become unwieldly huge and hard to manage.</p><p>Using the Context API allows for the separation of responsibilities without having to manually pass down everything through props.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*WbPcXbngidrNUP3zz98XvA.gif" /></figure><p>🤞🤞Ok, based on this answer, if we have several components in our React project and our components don’t have a lot of branching and the components don’t have a lot of interconnection,We can say that using props is logical and useful.</p><p>However, if the project is large and complex, if we had to create too many components and the components are interdependent, using Redux for larger projects with Context Api can be life-saving.</p><p>In my opinion,It is healthier to use props instead of using Context api in unnecessary situations. But accessories can help us to some extent. With the Context API, we can access the data we want from anywhere in the project. Obviously it has a structure that can be accessed everywhere.<br>Of course, there are cases where Context Api doesn’t work.<br>Let’s examine below;</p><p>I recommend checking it out <a href="https://blog.barisozcetin.me/using-composition-and-render-props-instead-context-api/">here</a>.</p><p><strong>Positive (+)</strong></p><p>• Only little setup is required — create context and sometimes wrapper component</p><p>• Well documented part of React</p><p>• A lot of local contexts to handle separate logic tasks can be in the application.</p><p><strong>Negative (-)</strong></p><p>• Context-API is not designed for often refreshed or changed data</p><p>• There could be more difficult maintenance in more complex frontend applications, especially if we have custom solutions and helpers</p><ul><li>Reuse components are harder, because some data come from context, not always from props</li></ul><p>For example, if the number of components starts to increase, the Context Api, which has a complex structure, will begin to lose its readability. This doesn’t follow <a href="https://gist.github.com/wojteklu/73c6914cc446146b8b533c0988cf8d29">clean code</a> guidelines. Of course, since the solution is not finished in React, the Redux structure comes into play in this part. There is more comprehensive information about these structures on <a href="https://reactjs.org/docs/getting-started.html">React’s</a> own site.</p><p>In summary, determining the structure I will use depends on us and the project we will do, each structure has its own advantages and disadvantages. I talked about when and in which situations Context Api should be preferred, why Props should be preferred and its advantages. I think it is a useful article.<br> <br>✔Keep researching and learning.✔</p><p>In my next article, I will discuss the advantages and disadvantages of Context Api and Redux. See you in my next article.🙌🙌</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad35dd1863e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What do Props and State do in React?]]></title>
            <link>https://medium.com/@omersnsz/what-do-props-and-state-do-in-react-da74ddf92911?source=rss-df0d72cd7984------2</link>
            <guid isPermaLink="false">https://medium.com/p/da74ddf92911</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[props]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[state]]></category>
            <dc:creator><![CDATA[Ömer Reşithan Sonsuz]]></dc:creator>
            <pubDate>Mon, 18 Apr 2022 18:41:37 GMT</pubDate>
            <atom:updated>2022-04-19T00:02:27.908Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*PAXKtH_sB5EuakkYRkR8DA.png" /></figure><p>Hello friends,</p><p>In this article, I will talk about the concepts of state and props for friends who want to improve themselves in React.</p><p>Case and accessories allow us to control components in our projects. Understanding the scene and situation is, in my opinion, one of the big most important steps in learning React. I will try to explain these concepts to you in a simple and explanatory way.</p><blockquote>What is Props Logic?</blockquote><p>In React Js, every component is actually a function. With the input values ​​we give to these functions, we determine how they will be seen and what kind of space they will occupy on the screen. We call these input values ​​props.<br>Props are read-only. They cannot be changed.<br>Data; While passing from the main component to the sub-components, it does not undergo any change by the sub-components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*zWLuFF9rCc4NME4R3_UD8w.png" /></figure><p>A simple button component that gets the text on it from outside through props. We can use this component over and over with different props.</p><h4>Using React Props</h4><p>We have a circle component in the figure below. The “color” and “size”props from the main component have been passed to this sub-component. Thus, color and size props values ​​in the circle component are assigned as “purple” and “large”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*hsBudXA0_iEFPuAwcJKtaA.png" /></figure><blockquote>What is State Logic?</blockquote><p>State definition is made in the constructor function, which will run every time our component is called from zero.</p><p>By calling from scratch, I mean more than mount, invoking a component that has not been rendered. Otherwise, the constructor is not called repeatedly in a mounted component that is already on our screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*OOJhHL7skle2rq5vgO7ElA.png" /></figure><p>What does the state do; It enables the render function of the component to run again whenever the state of the component called statefull component, which has a state definition in it, changes.</p><h4>Stateless Component Example</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*t-_kEc4xDDpY4wesI811HQ.png" /></figure><h4>Stateful Component Example</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*ohoSDo3NPdS4H4ezSB6snQ.png" /></figure><h4>Using Props and State Together</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*a5CbuKZyatAeg8xcNDF76w.png" /></figure><p>In the code snippet above, we kept the props values ​​in a state and accessed these values ​​with this.state inside the component.</p><h4>Differences between State and Props:</h4><p>1-)States change, Props cannot be changed.</p><p>2-)States are changed in the component, Props cannot be changed in the component.</p><p>3-) Props can be in function, they cannot be changed by the main component.</p><p>4-)States can pass to subcomponents as props. Props can be used in stateless components.</p><p>5-) States “this.state.name”,Props “this.props.name”.</p><p>6-)setState method triggers rendering, props provide communication between components.</p><p>7-) While updating the state, the setState() method is used, data is transferred from the main component to the child component.</p><p>— — — — — — — — — — — — — — — — — — — — —</p><p>I tried to talk about situations and accessories as short and detailed as I can, friends. I hope it was useful. See you again.🙌</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da74ddf92911" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is the Context API ??]]></title>
            <link>https://medium.com/@omersnsz/what-is-the-context-api-8ca19608bd5c?source=rss-df0d72cd7984------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ca19608bd5c</guid>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[context-api]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Ömer Reşithan Sonsuz]]></dc:creator>
            <pubDate>Mon, 18 Apr 2022 17:19:02 GMT</pubDate>
            <atom:updated>2022-04-18T17:19:02.384Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is the Context API ??</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*YfoLYEypQZRsALEsof5CUw.png" /></figure><p>While developing applications with React.js, we define states and pass these states to the components we will use with the help of props. When we want to use this state in components at the same level, we have to move the state to the component one level higher. This flow may not be a problem in simple applications. However, as the application grows and the number of components increases, managing the state and ensuring that the components use this state can become a big problem.</p><p>Let’s try to understand this problem with a small example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*p_LstpMu1ITgoDcAHknU4g.png" /></figure><p>Looking at the code sample.We transferred the theme state to the ModeSwitcher component two levels below with the help of props.So what would we do if we wanted to pass this state to a component 10 levels below?😱😱</p><p>To solve this and similar problems, we need to use the React Context API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Ylvid0cjGwkVKewhTPUrg.png" /></figure><h4>How can I use Context Api?</h4><p>1-)To create a usable state, our priority is to create a context.</p><p>2-)The React.createContext() method is used to create the context.</p><p>3-)This method takes a parameter that we can set a default value for the context we created.</p><p>4-)In order to use the context we created, we need two special components, Context Provider and Context Consumer.</p><h3>👪Context.Provider</h3><p>Context Provider is a component that provides access to the components that will use the context we have created, enables these components to be re-rendered in context updates, and derives from the context we have created. This component takes a prop named value and with this prop, context values ​​are passed to child components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*3pmgLYQ8vE0_3VpQOluIig.png" /></figure><p>🚀Here, it should be noted that the Context Provider component is the parent of the components that will use the context. Otherwise, components cannot access context.</p><h3>👦Context.Consumer👧</h3><p>Context Consumer components make the context values ​​sent with the Context Provider accessible in the components we will use.</p><p>We get a function with a parameter called this component value and we can access the context values ​​in the body of this function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*iZLkD1P0O8OnABMRPGm7iw.png" /></figure><p>I do not find this method healthy for components that use more than one context.</p><p>Because for the component that uses more than one context, I think this method makes it complex and unorganized.</p><p>There are 2 more methods for components to access context values. I think it would be more logical not to use Context Consumer components.</p><p>You can find React’s own documentation <a href="https://reactjs.org/docs/context.html">here</a>.</p><p>See you again. Keep Learning and Researching.🙌</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ca19608bd5c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Components(React Bileşenleri)]]></title>
            <link>https://medium.com/@omersnsz/react-components-react-bile%C5%9Fenleri-7824cd3cc6f6?source=rss-df0d72cd7984------2</link>
            <guid isPermaLink="false">https://medium.com/p/7824cd3cc6f6</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[components]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Ömer Reşithan Sonsuz]]></dc:creator>
            <pubDate>Mon, 18 Apr 2022 13:57:52 GMT</pubDate>
            <atom:updated>2022-04-18T14:45:53.339Z</atom:updated>
            <content:encoded><![CDATA[<p>According to me, A web page can be divided into small subsections that do their own thing.We call these special parts, each of which does its own thing, components.Think of your site as one big puzzle.<br>With React, you first create puzzle pieces one by one, and then combine them to create the big picture.</p><p>For example, we can divide the Medium page into three components;<br>profile, post and topic component is as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*D4-GjyndM2t1Zd3Qb9b6Fw.png" /></figure><p>React Components are building blocks that shape the user interface, have specific tasks, are defined as classes or functions, return react elements (JSX), and optionally take parameters (props).<br>There are basically two types of components. These are Class-Based and Functional components. Let’s see what they are.</p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — —</p><h3>Class-Based Components (Sınıf Tabanlı)</h3><p>Considering that you have mastered the logic of inheritance, which is one of the subjects included in the object-oriented programming approach.I would say as javascript classes that extend from the “Component” class in the React library.</p><p>Since these classes extend from React Component, they also include Component Lifecycle processes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pHGVRrkitbPDmI7TShxbAA.png" /></figure><p>Basic class-based component as in the figure above<br>you can be created.</p><h3>Functional Components (Foksiyonel)</h3><p>Also called dummy and dumb component,Basically React elements(JSX) are javascript functions that return.The reason is basically because they can’t access state.This structure has changed with version <strong>v.16.8.</strong>Now functional components can also access state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*E8ZXoODC79K-U-rZks7VZw.png" /></figure><p>With the v.16.8 version, there is not much difference between the two component types, apart from syntax.It is completely up to us to choose the component according to the purpose of use, according to the work you will do.</p><p>— — — — — — — — — — — — — — — — — — — — — — — — —</p><p>If you ask what are the differences between Functional component and Class component.</p><blockquote>=&gt; Hooks can only be used in functional components.</blockquote><blockquote>=&gt;Lifcycle methods can only be used in class components.</blockquote><p>— — — — — — — — — — — — — — — — — — — — — — — — —</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7824cd3cc6f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>