
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Latest News</title>
<link>https://sl2.ymaws-qa.com/news/default.asp</link>
<description><![CDATA[ Keep up-to-date with the latest news straight from&nbsp;us to you! ]]></description>
<lastBuildDate>Tue, 5 May 2026 16:43:36 GMT</lastBuildDate>
<pubDate>Mon, 25 Feb 2019 15:27:54 GMT</pubDate>
<copyright>Copyright &#xA9; 2019 SocialLink2 QA Site</copyright>
<atom:link href="https://sl2.ymaws-qa.com/news/news_rss.asp?cat=2278" rel="self" type="application/rss+xml"></atom:link>
<item>
<title>4 ways to style React Components</title>
<link>https://sl2.ymaws-qa.com/news/news.asp?id=11418</link>
<guid>https://sl2.ymaws-qa.com/news/news.asp?id=11418</guid>
<description><![CDATA[<p name="3638" id="3638">This is the fourth part of my React tutorials. See the Intro to react.js <a href="https://medium.com/p/a37696fd99af" data-href="https://medium.com/p/a37696fd99af" target="_blank">here</a></p>
<p name="bcf7" id="bcf7">There are four different options to style React components. All depend on your personal preferences and the specific complexity of your application.</p>
<p name="171e" id="171e">If you want to add just a few style properties, then <strong>inline styling</strong> is the best option.</p>
<p name="8427" id="8427">When you want to reuse your style properties in the same file then <strong>style-component</strong> are perfect.</p>
<p name="c564" id="c564">When your application is more complex I recommend <strong>CSS Modules</strong> or regular <strong>CSS stylesheets.</strong></p>
<h4 name="a8cf" id="a8cf">1. CSS Stylesheet</h4>
<figure name="0c9c" id="0c9c">
<div>&nbsp;</div>
</figure>
<ul>
    <li name="c5da" id="c5da">Simply import css file <code>import './DottedBox.css'</code> so you can have a separate css file for each component.</li>
</ul>
<figure name="a376" id="a376">
<div>&nbsp;</div>
</figure>
<h4 name="aeb1" id="aeb1">2. Inline&nbsp;styling</h4>
<p name="3263" id="3263">In React, inline styles are not specified as a string. Instead they are specified with an object whose <strong>key</strong> is the <strong>camelCased</strong> version of the style name, and whose value is the style’s value, usually<span name="anon_70c4633070a0" data-creator-ids="anon"> </span>a string.</p>
<figure name="3840" id="3840">
<div>&nbsp;</div>
</figure>
<ul>
    <li name="3ba4" id="3ba4">We can create a variable that stores style properties and then pass it to the element like <code>style={nameOfvariable}</code></li>
    <li name="fbf4" id="fbf4">We can also pass the styling directly <code>style={{color: 'pink'}}</code></li>
</ul>
<h4 name="2c46" id="2c46">3. CSS&nbsp;Modules</h4>
<p name="03e5" id="03e5">A CSS Module is a CSS file in which all class names and animation names are scoped locally by default. Great article about css modules <a href="https://medium.com/@pioul/modular-css-with-react-61638ae9ea3e#.re1pdcz87" data-href="https://medium.com/@pioul/modular-css-with-react-61638ae9ea3e#.re1pdcz87" target="_blank">here</a>.</p>
<figure name="a39f" id="a39f">
<div>&nbsp;</div>
</figure>
<ul>
    <li name="4b75" id="4b75">Similar to css we import css file <code>import styles './DashedBox.css'</code></li>
    <li name="0576" id="0576">then we access to className as we access to object</li>
</ul>
<figure name="6a62" id="6a62">
<div>&nbsp;</div>
</figure>
<p name="703e" id="703e"><code>:local(.className)</code>-this when you use create-react-app because of webpack configurations</p>
<p name="3b0e" id="3b0e"><code>.className</code>-this if you use your own react boilerplate.</p>
<p name="8ddc" id="8ddc">To make CSS modules work with Webpack you only have to include the modules mentioned above and add the following loader to your <code>webpack.config.js</code> file:</p>
<pre name="d749" id="d749"><code>. . .<br />{<br /> test: /\.css$/,<br /> loader: 'style!css-loader?modules&amp;importLoaders=1&amp;localIdentName=[name]__[local]___[hash:base64:5]' <br />}<br />. . .</code></pre>
<h4 name="d230" id="d230">4. Styled-components 💅</h4>
<p name="e0da" id="e0da"><a href="https://github.com/styled-components/styled-components" data-href="https://github.com/styled-components/styled-components" rel="noopener" target="_blank">Styled-components</a> is a library for React and React Native that allows you to use component-level styles in your application that are written with a mixture of JavaScript and CSS</p>
<figure name="a321" id="a321">
<div>&nbsp;</div>
</figure>
<ul>
    <li name="b84f" id="b84f">First we need to install <code>styled-components</code> library</li>
    <li name="b88c" id="b88c"><code>npm install styled-components --save</code></li>
    <li name="b31c" id="b31c">Now we can create a variable by selecting a particular html element where we store our style keys <code>const Div = styled.htmlElemnet`color: pink`</code></li>
    <li name="6646" id="6646">Then we use the name of our variable as a wrapper <code>&lt;Div&gt;&lt;/Div&gt;</code> kind of react component:)</li>
    <li name="2f02" id="2f02">Tips to use emoji icons key shortcut <code>CTRL+CMD+SPACE</code> 💡</li>
</ul>
<p name="c6d3" id="c6d3">All these ways of styling react components have pros and cons.</p>
<p name="ba2f" id="ba2f">It all boils down to both your own personal preferences and the specific complexity of your application.</p>
<p name="1d6f" id="1d6f">I suggest you to make 4 projects, each using different way of style.</p>
<p name="09d8" id="09d8">Enjoy 😃</p>]]></description>
<pubDate>Mon, 25 Feb 2019 16:27:54 GMT</pubDate>
</item>
<item>
<title>wewef</title>
<link>https://sl2.ymaws-qa.com/news/news.asp?id=11417</link>
<guid>https://sl2.ymaws-qa.com/news/news.asp?id=11417</guid>
<description><![CDATA[<p id="orgoname-field-emind">Custom.CSS</p>
<p id="orgoname-field-emind-2">Metatags &amp; CSS</p>
<p id="orgoname-field-emind-3">YADMIN Custom CSS</p>]]></description>
<pubDate>Tue, 28 Aug 2018 18:47:28 GMT</pubDate>
</item>
</channel>
</rss>
