<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: JC Latam</title>
    <description>The latest articles on DEV Community by JC Latam (@jc21romadulce).</description>
    <link>https://dev.to/jc21romadulce</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F866368%2F04257b5b-c1e0-4def-a98a-bd21f1188cfa.jpeg</url>
      <title>DEV Community: JC Latam</title>
      <link>https://dev.to/jc21romadulce</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jc21romadulce"/>
    <language>en</language>
    <item>
      <title>What is Styled-Components?</title>
      <dc:creator>JC Latam</dc:creator>
      <pubDate>Thu, 26 May 2022 17:56:06 +0000</pubDate>
      <link>https://dev.to/jc21romadulce/what-is-styled-components-51o</link>
      <guid>https://dev.to/jc21romadulce/what-is-styled-components-51o</guid>
      <description>&lt;h1&gt;
  
  
  beginings
&lt;/h1&gt;

&lt;p&gt;Styled-components is a popular library that is used to style React applications. It allows you to build custom components by writing actual CSS in your JavaScript.&lt;/p&gt;

&lt;p&gt;In this article, we will take a look at how to use styled-components in a React application.&lt;/p&gt;

&lt;p&gt;By the end of the article, you should have an understanding of how to do the following:&lt;/p&gt;

&lt;p&gt;Create a styled component&lt;br&gt;
Pass props to a styled component&lt;br&gt;
Create and use a theme&lt;br&gt;
Before we dive into the code, let’s first do a quick overview of the styled-components library and understand the benefits of using it.&lt;/p&gt;

&lt;p&gt;What Is Styled-Components?&lt;br&gt;
There are many options you can take when it comes to styling a React application. The traditional way would be to create an external CSS file, then pass the attributes as a string on the className prop.&lt;/p&gt;

&lt;p&gt;You can also use the CSS-in-JS technique, where you write the CSS in the JavaScript file. Styled-components takes this approach.&lt;/p&gt;

&lt;p&gt;“Use the best bits of ES6 and CSS to style your apps without stress.” — styled-components website&lt;/p&gt;

&lt;p&gt;Benefits of using styled-components&lt;br&gt;
Automatic critical CSS — styled-components keeps track of which components are rendered on a page and only adds their styles&lt;br&gt;
No class name bugs — styled-components generates a unique class name for the styles&lt;br&gt;
Easier deletion of CSS — styles are tied to a specific component rather than being added as a class name&lt;br&gt;
Simple dynamic styling — styles can be added to a component based on props or a theme&lt;br&gt;
Painless maintenance — styles added to a component is done all in one place, rather than across multiple files&lt;br&gt;
Automatic vendor prefixing — styled-components handles all of this&lt;br&gt;
Create a Styled Component&lt;br&gt;
To get started, let’s create our first styled component. I will be working on a basic create-react-app project with TypeScript support. You can follow along with or without TypeScript.&lt;/p&gt;

&lt;p&gt;The conventional way to name a file when using styled-components is componentName.styled.ts. Where “componentName” is replaced with the name of the component.&lt;/p&gt;

&lt;p&gt;For example, I will create a new file called /src/components/styles/Button.styled.ts. This is where I will create my  component.&lt;/p&gt;

&lt;p&gt;In this file, first import styled from 'styled-components';. Then, you can use styled to create a styled component.&lt;/p&gt;

&lt;p&gt;“Styled components utilises tagged template literals to style your components.” — styled-components website&lt;/p&gt;

&lt;p&gt;In other words, when you are defining styles, you are actually creating a component that has the styles attached to it using template literals.&lt;/p&gt;

&lt;p&gt;First, type styled. followed by a valid React component or a tagname like ‘div’. For this example, we will create a styled button component.&lt;/p&gt;

&lt;p&gt;export const Button = styled.button&lt;code&gt;&lt;br&gt;
  background-color: springGreen;&lt;br&gt;
  color: black;&lt;br&gt;
  font-size: 16px;&lt;br&gt;
  border-radius: 4px;&lt;br&gt;
  padding: 0.5rem 1rem;&lt;br&gt;
  margin: 1rem;&lt;br&gt;
  cursor: pointer;&lt;br&gt;
  border: none;&lt;br&gt;
  outline: none&lt;/code&gt;;&lt;/p&gt;

&lt;p&gt;We can now use this Button component like any normal  element in our app.&lt;/p&gt;

&lt;p&gt;Styled Button&lt;/p&gt;

&lt;p&gt;When we render the button, it will now have all of the styles with it.&lt;br&gt;
Source:&lt;a href="https://betterprogramming.pub/introduction-to-styled-components-in-react-d84583c28dde"&gt;https://betterprogramming.pub/introduction-to-styled-components-in-react-d84583c28dde&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>State vs Props</title>
      <dc:creator>JC Latam</dc:creator>
      <pubDate>Mon, 23 May 2022 04:15:18 +0000</pubDate>
      <link>https://dev.to/jc21romadulce/state-vs-props-4in7</link>
      <guid>https://dev.to/jc21romadulce/state-vs-props-4in7</guid>
      <description>&lt;p&gt;Props and state are related. The state of one component will often become the props of a child component. Props are passed to the child within the render method of the parent as the second argument to React.createElement() or, if you're using JSX, the more familiar tag attributes.&lt;/p&gt;

&lt;p&gt;Source: &lt;a href="https://stackoverflow.com/"&gt;https://stackoverflow.com/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>What is a component in react?</title>
      <dc:creator>JC Latam</dc:creator>
      <pubDate>Mon, 23 May 2022 04:13:24 +0000</pubDate>
      <link>https://dev.to/jc21romadulce/what-is-a-component-in-react-2ion</link>
      <guid>https://dev.to/jc21romadulce/what-is-a-component-in-react-2ion</guid>
      <description>&lt;p&gt;Components are the building blocks of any React app and a typical React app will have many of these. Simply put, a component is a JavaScript class or function that optionally accepts inputs i.e. properties(props) and returns a React element that describes how a section of the  User Interface should appear.&lt;/p&gt;

&lt;p&gt;You can create your first component like this code:&lt;br&gt;
const Greeting = () =&amp;gt; &lt;/p&gt;
&lt;h1&gt;Hello World today!&lt;/h1&gt;;

&lt;p&gt;Source:&lt;a href="https://medium.com/the-andela-way/understanding-react-components37f841c1f3bb#:%7E:text=Components%20are%20the%20building%20blocks,(User%20Interface)%20should%20appear"&gt;https://medium.com/the-andela-way/understanding-react-components37f841c1f3bb#:~:text=Components%20are%20the%20building%20blocks,(User%20Interface)%20should%20appear&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>What is React?</title>
      <dc:creator>JC Latam</dc:creator>
      <pubDate>Mon, 23 May 2022 04:08:48 +0000</pubDate>
      <link>https://dev.to/jc21romadulce/what-is-react-6aa</link>
      <guid>https://dev.to/jc21romadulce/what-is-react-6aa</guid>
      <description>&lt;p&gt;Well..React is a JavaScript library created by Facebook. React is a User Interface (UI) library. React is a tool for building UI components.&lt;br&gt;
Source: &lt;a href="https://www.w3schools.com/whatis/whatis_react.asp"&gt;https://www.w3schools.com/whatis/whatis_react.asp&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
