<?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: Doaa Shafik </title>
    <description>The latest articles on DEV Community by Doaa Shafik  (@doaashafik).</description>
    <link>https://dev.to/doaashafik</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%2F383799%2F42df4a22-60b2-4edb-b675-0a26a05f5955.png</url>
      <title>DEV Community: Doaa Shafik </title>
      <link>https://dev.to/doaashafik</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/doaashafik"/>
    <language>en</language>
    <item>
      <title>CSS PreProcessor </title>
      <dc:creator>Doaa Shafik </dc:creator>
      <pubDate>Fri, 19 Feb 2021 21:06:55 +0000</pubDate>
      <link>https://dev.to/doaashafik/css-preprocessor-48n6</link>
      <guid>https://dev.to/doaashafik/css-preprocessor-48n6</guid>
      <description>&lt;h3&gt;What is CSS PreProcessor? &lt;/h3&gt;

&lt;p&gt;A CSS preprocessor is a language extension for CSS. &lt;br&gt;
it adds some features that don't exist in pure CSS, such as mixin, nesting selector, inheritance selector, and so on. it helps keep large stylesheets well-organized and makes it easy to share designs within and across projects.&lt;/p&gt;

&lt;p&gt;There are different types of CSS preprocessors, &lt;code&gt;Stylus, SASS, LESS&lt;/code&gt;.&lt;br&gt;
We will discuss SASS, LESS and make a comparison between them.&lt;/p&gt;

&lt;h3&gt;LESS VS SASS&lt;/h3&gt;

&lt;p&gt;LESS and Sass share a lot of similarities in syntax, including the following:&lt;/p&gt;

&lt;p&gt;Mixins: &lt;strong&gt;"mix-in" properties from existing styles&lt;/strong&gt;&lt;br&gt;
Variables: &lt;strong&gt;Shared code between styles&lt;/strong&gt;&lt;br&gt;
Parametric mixins: &lt;strong&gt;Classes to which you can pass parameters, like functions&lt;/strong&gt;&lt;br&gt;
Nested Rules: &lt;strong&gt;Classes within classes, which cut down on repetitive code&lt;/strong&gt;&lt;br&gt;
Operations: &lt;strong&gt;arithmetic operations within CSS&lt;/strong&gt;&lt;br&gt;
Color functions: &lt;strong&gt;Edit your colors&lt;/strong&gt;&lt;br&gt;
Namespaces: &lt;strong&gt;Groups of styles that can be called by references&lt;/strong&gt;&lt;br&gt;
Scope: &lt;strong&gt;Make local changes to styles&lt;/strong&gt;&lt;br&gt;
JavaScript evaluation: &lt;strong&gt;JavaScript expressions evaluated in CSS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For More Info... check &lt;br&gt;
&lt;a href="http://lesscss.org/usage/"&gt;Less Docs&lt;/a&gt;&lt;br&gt;
&lt;a href="https://sass-lang.com/documentation"&gt;SASS Docs&lt;/a&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;h3&gt;SASS&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Installation&lt;/code&gt;&lt;br&gt;
 Depend on the operating system You use&lt;br&gt;
 &lt;a href="https://sass-lang.com/install"&gt;Install/SASS&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;PROS&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;1- You are able to declare functions with Sass as regular functions&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;
 @function invert($color, $amount: 100%) {
   $inverse: change-color($color, $hue: hue($color) + 180);
   @return mix($inverse, $color, $amount);
 }
&lt;/code&gt;
&lt;/pre&gt;

&lt;p&gt;2- Sass simplifies minifying CSS files by offering a one-line command that will output a minified version&lt;br&gt;
&lt;code&gt;sass input.scss:output.css --style compressed&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;3- Rather than being limited to editing the outputted CSS file in dev tools, with source maps you are able to manipulate the original .scss file&lt;br&gt;
To enable source map&lt;br&gt;
&lt;code&gt;sass style.scss:style.css --sourcemap&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;CONS&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;1- To compile Sass, it needs either Ruby or libSass installed locally.&lt;/p&gt;

&lt;p&gt;2- There is many unnecessary characters when using the SCSS syntax.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;h3&gt;LESS&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Installation&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Less is written in JavaScript so you will need Node.&lt;br&gt;
1- On Linux and Mac, &lt;br&gt;
   Then Install &lt;code&gt;npm install -g less&lt;/code&gt;&lt;br&gt;
   To Compile it &lt;code&gt;lessc styles.less styles.css&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;2- On Windows, you will need to install the NodeJS installer.&lt;br&gt;
   Then Install &lt;code&gt;npm install less&lt;/code&gt;&lt;br&gt;
   To Compile it &lt;code&gt;lessc styles.less styles.css&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;PROS&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;1- The LESS syntax is essentially the same as CSS with extensions for dynamic behavior such as variables, mixins, operations, and functions.&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;
 @color: #4D926F;
 #footer {
   color: @color;
 }
 h2,
 h1 { 
   color: @color;
 }
&lt;code&gt;&lt;/code&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;2- Less has detailed and well-organized documentation&lt;/p&gt;

&lt;p&gt;&lt;code&gt;CONS&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;1- The '@' symbol is used with Less to declare variables. &lt;br&gt;
However '@' already has meaning in CSS, as it is used to declare @media queries and @keyframes. This can result in some confusion when reading the code&lt;/p&gt;

&lt;p&gt;2- Less currently has limited support of conditionals such as ternary operators&lt;/p&gt;

&lt;p&gt;3- Less does not offer custom functions like &lt;code&gt;SASS&lt;/code&gt; and instead requires the use of &lt;a href="http://lesscss.org/features/#mixins-feature"&gt;Mixins&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Your Feedback Appreciated.&lt;/p&gt;

</description>
      <category>sass</category>
      <category>less</category>
      <category>css</category>
    </item>
    <item>
      <title>Formik vs React-hook-form Cases Part II</title>
      <dc:creator>Doaa Shafik </dc:creator>
      <pubDate>Mon, 08 Feb 2021 13:25:46 +0000</pubDate>
      <link>https://dev.to/doaashafik/formik-vs-react-hook-form-cases-part-ii-3ofj</link>
      <guid>https://dev.to/doaashafik/formik-vs-react-hook-form-cases-part-ii-3ofj</guid>
      <description>&lt;h3&gt;Nested Arrays&lt;/h3&gt;

&lt;p&gt;react-hook-form handle it with &lt;a href="https://react-hook-form.com/api#useFieldArray"&gt;useFieldArray&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;formik handle array fields with &lt;a href="https://formik.org/docs/api/fieldarray"&gt;FieldArray&lt;/a&gt;&lt;br&gt;
&lt;iframe src="https://codesandbox.io/embed/focused-galois-5918f"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;Nested Array Validation&lt;/h3&gt;

&lt;p&gt;react-hook-form by default validate input inSubmit only.&lt;br&gt;
To enable it on other events, you need custom changes.&lt;br&gt;
see &lt;a href="https://react-hook-form.com/api#trigger"&gt;trigger&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;formik by default validate input in all events.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/validate-nestedarr-formikreacthookform-8owd9"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;Integrate with Material UI&lt;/h3&gt;

&lt;p&gt;react-hook-form we can integrate external controlled components like &lt;code&gt;react-select&lt;/code&gt; with &lt;a href="https://react-hook-form.com/api#Controller"&gt;Controller&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;formik you can render external controlled component by itself. Look at example&lt;br&gt;
&lt;iframe src="https://codesandbox.io/embed/sweet-wright-c0vx5"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>Formik VS React Hook Form Part I</title>
      <dc:creator>Doaa Shafik </dc:creator>
      <pubDate>Sun, 07 Feb 2021 10:29:56 +0000</pubDate>
      <link>https://dev.to/doaashafik/formik-vs-react-hook-form-aei</link>
      <guid>https://dev.to/doaashafik/formik-vs-react-hook-form-aei</guid>
      <description>&lt;p&gt;Front End Engineers work a lot with forms and with the complexity of apps we need powered forms to help us managing the form state, form validation with nested levels, form verbosity.&lt;br&gt;
&lt;a href="https://formik.org/" rel="noopener noreferrer"&gt;Formik&lt;/a&gt; comes to solve all these problems.&lt;br&gt;
Now we have a new library &lt;a href="https://react-hook-form.com/" rel="noopener noreferrer"&gt;React Hook Form&lt;/a&gt; &lt;span&gt;was released to compete.&lt;/span&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;h3&gt;Module Composition&lt;/h3&gt; 

&lt;p&gt;&lt;a href="https://bundlephobia.com/result?p=formik@1.5.8" rel="noopener noreferrer"&gt;Formik has nine dependencies&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi2.wp.com%2Fblog.logrocket.com%2Fwp-content%2Fuploads%2F2019%2F10%2Fformik-dependencies.png%3Fresize%3D730%252C155%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi2.wp.com%2Fblog.logrocket.com%2Fwp-content%2Fuploads%2F2019%2F10%2Fformik-dependencies.png%3Fresize%3D730%252C155%26ssl%3D1" alt="formik composition"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://bundlephobia.com/result?p=react-hook-form@3.24.0" rel="noopener noreferrer"&gt;React Hook Form has no dependencies&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi2.wp.com%2Fblog.logrocket.com%2Fwp-content%2Fuploads%2F2019%2F10%2Freact-hook-form-dependencies.png%3Fw%3D730%26ssl%3D1%2520730w%2C%2520https%3A%2F%2Fi2.wp.com%2Fblog.logrocket.com%2Fwp-content%2Fuploads%2F2019%2F10%2Freact-hook-form-dependencies.png%3Fresize%3D300%252C34%26ssl%3D1%2520300w" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi2.wp.com%2Fblog.logrocket.com%2Fwp-content%2Fuploads%2F2019%2F10%2Freact-hook-form-dependencies.png%3Fw%3D730%26ssl%3D1%2520730w%2C%2520https%3A%2F%2Fi2.wp.com%2Fblog.logrocket.com%2Fwp-content%2Fuploads%2F2019%2F10%2Freact-hook-form-dependencies.png%3Fresize%3D300%252C34%26ssl%3D1%2520300w" alt="React Hook Form bundle"&gt;&lt;/a&gt;&lt;br&gt;
&lt;span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;h3&gt;How easy is it to solve complex form constructs?&lt;/h3&gt;

&lt;p&gt;For Complex Features "Nested array" or "nested objects"&lt;br&gt;
Formik handles it perfectly with validation on different events like onblur - onchange.&lt;/p&gt;

&lt;p&gt;react-hook-form handle it but the validation of nested fields with "onblur" or "onchange" needs some works.&lt;/p&gt;

&lt;p&gt;For simplicity, I see formik win cause it handles more stuff behind without the need to add it by yourself.&lt;/p&gt;

&lt;h3&gt;Controlled &amp;amp; UnControlled Component&lt;/h3&gt;

&lt;p&gt;Formik support Only Controlled Component but React-hook-form support both of them.&lt;/p&gt;

&lt;h6&gt;
  
  
  Controlled Component
&lt;/h6&gt;

&lt;p&gt;is one that takes its current value through props and notifies changes through callbacks like onChange. A parent component "controls" it by handling the callback and managing its own state and passing the new values as props to the controlled component.&lt;br&gt;
&lt;a href="https://react-hook-form.com/api#Controller" rel="noopener noreferrer"&gt;Controlled Component with RHF&lt;/a&gt;&lt;br&gt;
&lt;a href="https://formik.org/docs/api/field" rel="noopener noreferrer"&gt;Controlled Component with Formik&lt;/a&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  Uncontrolled Component
&lt;/h6&gt;

&lt;p&gt;is one that stores its own state internally, and you query the DOM using a ref to find its current value when you need it.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;feature&lt;/th&gt;
      &lt;th&gt;uncontrolled&lt;/th&gt;
      &lt;th&gt;controlled&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;one-time value retrieval (e.g. on submit)&lt;/td&gt;
      &lt;td&gt;✅&lt;/td&gt;
      &lt;td&gt;✅&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;validating on submit&lt;/td&gt;
      &lt;td&gt;✅&lt;/td&gt;
      &lt;td&gt;✅&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;conditionally disabling submit button&lt;/td&gt;
      &lt;td&gt;❌&lt;/td&gt;
      &lt;td&gt;✅&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;several inputs for one piece of data&lt;/td&gt;
      &lt;td&gt;❌&lt;/td&gt;
      &lt;td&gt;✅&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;dynamic inputs&lt;/td&gt;
      &lt;td&gt;❌&lt;/td&gt;
      &lt;td&gt;✅&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;br&gt;&lt;/p&gt;

&lt;h3&gt;Re-Rendering&lt;/h3&gt;

&lt;p&gt;We want to avoid unnecessary re-render cycles as much as possible, as this could lead to major performance issues as an app grows.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2Fz8GNRbz%2F68747470733a2f2f692e737461636b2e696d6775722e636f6d2f664232704a2e706e67.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2Fz8GNRbz%2F68747470733a2f2f692e737461636b2e696d6775722e636f6d2f664232704a2e706e67.png" alt="image-rerender-formik &amp;amp; react-hook-form"&gt;&lt;/a&gt;&lt;br&gt;
&lt;span&gt;&lt;/span&gt;&lt;/p&gt;

&lt;h3&gt;Dependent Fields&lt;/h3&gt;

&lt;p&gt;With React Hook Form &lt;a href="https://react-hook-form.com/api#watch" rel="noopener noreferrer"&gt;watch Function&lt;/a&gt; help you to watch specified inputs and return their values to  determine what to render. &lt;/p&gt;

&lt;p&gt;With Formik watching all fields enabled by default so you can remove or add fields depend on values prop.&lt;br&gt;
&lt;span&gt;&lt;/span&gt;&lt;br&gt;&lt;/p&gt;

&lt;h3&gt;Events&lt;/h3&gt;

&lt;p&gt;With React Hook Form &lt;a href="https://react-hook-form.com/api#getValues" rel="noopener noreferrer"&gt;Read Form Values&lt;/a&gt; inside events.&lt;/p&gt;

&lt;h6&gt;
  
  
  note: getValues() will not trigger re-renders or subscribe to input changes.
&lt;/h6&gt;

&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;br&gt;
With Formik you can read form values with values prop.&lt;br&gt;
&lt;span&gt;&lt;/span&gt;&lt;br&gt;&lt;/p&gt;

&lt;h3&gt;Summarize&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
    &lt;thead&gt;
        &lt;tr&gt;
            &lt;th&gt;feature&lt;/th&gt;
            &lt;th&gt;formik&lt;/th&gt;
            &lt;th&gt;react-hook-form&lt;/th&gt;
        &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td&gt;Size&lt;/td&gt;
            &lt;td&gt;12.6kB&lt;/td&gt;
            &lt;td&gt;5.2kB&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;Weekly Downloads&lt;/td&gt;
            &lt;td&gt;1,314,511&lt;/td&gt;
            &lt;td&gt;638,419&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;Dependencies&lt;/td&gt;
            &lt;td&gt;9&lt;/td&gt;
            &lt;td&gt;0&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;Open Issues&lt;/td&gt;
            &lt;td&gt;498&lt;/td&gt;
            &lt;td&gt;6&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;React Native&lt;/td&gt;
            &lt;td&gt;✅&lt;/td&gt;
            &lt;td&gt;✅&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;TypeScript&lt;/td&gt;
            &lt;td&gt;✅&lt;/td&gt;
            &lt;td&gt;✅&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;Class components&lt;/td&gt;
            &lt;td&gt;✅&lt;/td&gt;
            &lt;td&gt;❌&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;Clear documentation&lt;/td&gt;
            &lt;td&gt;✅&lt;/td&gt;
            &lt;td&gt;✅&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;Yup integration&lt;/td&gt;
            &lt;td&gt;✅&lt;/td&gt;
            &lt;td&gt;✅&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;br&gt;
Compare Both with Examples, See &lt;a href="https://dev.to/doaashafik/formik-vs-react-hook-form-cases-part-ii-4omi-temp-slug-5264081?preview=e42653392509226354193f68854f7627a98ae96e623513580c189866db12b7ce03c9b7205e1d83b0254124ae37f2ea476b0a0f1a560c9d7da54188e6"&gt;Formik VS React Hook Form Part II&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>html</category>
      <category>formik</category>
      <category>reacthookform</category>
    </item>
  </channel>
</rss>
