<?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 Izik Orgad on Medium]]></title>
        <description><![CDATA[Stories by Izik Orgad on Medium]]></description>
        <link>https://medium.com/@izikorgad?source=rss-1faa712b56f6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*LyvQa1fQLRFHr6yKMF4vnQ@2x.jpeg</url>
            <title>Stories by Izik Orgad on Medium</title>
            <link>https://medium.com/@izikorgad?source=rss-1faa712b56f6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 08:12:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@izikorgad/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[Writing Forms in React]]></title>
            <link>https://medium.com/react-redux-best-practice/writing-forms-in-react-1b3b708366f2?source=rss-1faa712b56f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b3b708366f2</guid>
            <category><![CDATA[npm]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[forms]]></category>
            <category><![CDATA[statful]]></category>
            <dc:creator><![CDATA[Izik Orgad]]></dc:creator>
            <pubDate>Sun, 22 Apr 2018 14:42:15 GMT</pubDate>
            <atom:updated>2018-04-22T14:42:15.917Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*JO1XKNEwg-S8KvCauBUT-Q.png" /></figure><p>HTML forms are hard…<br>Developing forms in react could be even harder:</p><p>We have to render each input control using its recent value, but still to maintain the overall form state so we’ll be able to submit its values in a single transaction.</p><p>Take a look over the following naive implementation:<br>Fill both inputs and hit ‘submit’.<br>Now - check the ‘Use default values’ checkbox and try again.</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fcodepen.io%2FIzikorgad%2Fpen%2FLQKOeY&amp;src=https%3A%2F%2Fcodepen.io%2FIzikorgad%2Fembed%2Fpreview%2FLQKOeY%3Fheight%3D600%26slug-hash%3DLQKOeY%26default-tabs%3Djs%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io%26embed-version%3D2&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/9b61b115ca26c49e7a52e8ae400b98aa/href">https://medium.com/media/9b61b115ca26c49e7a52e8ae400b98aa/href</a></iframe><p>What went wrong?<br>By initiating the input with props value, <strong>user changes stop to take affect</strong>.</p><h4>Controlled Components</h4><p>One approach to overcome this known issue is the <a href="https://reactjs.org/docs/forms.html">Controlled Components</a>. The general idea behind this pattern is to use the container component state to render input values. Each change should affect the state and cause a new rendering cycle with the newly updated value.</p><p>However, using this pattern enforce us to implement a dedicated from-container component with its own predefined state each time.<br>Over and over again…</p><p>There are some other great solutions that targeting this problem like <a href="https://react-form.js.org/#/">react-from</a> or <a href="https://redux-form.com/7.3.0/">redux-from</a>, but both of them are only for redux based apps.<br>Further more, the overhead of using redux to store each form-element current value is huge, but event if we’ll ignore this fact - storing component inner-state as part of the global application store is a bad practice.</p><h4>Stateful Forms</h4><p>I’d like to suggest a new approach, using only react native API. <br>What if — we’ll be able to use controlled-components strength but also preserve common reusable functionality?</p><p>In order to do so, we’ll have to agree over a common field ← → form interface:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09a3923c6c04b1e36936078685f9dd76/href">https://medium.com/media/09a3923c6c04b1e36936078685f9dd76/href</a></iframe><p>The Filed component is a general controlled-component, it has an initial value defined by its props.value, and a internal state.newValue been updated by user interaction.</p><p>Now, let’s have a look over the Form component implementation:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/68b94b5b16cb6952b8ef3ebbdc897696/href">https://medium.com/media/68b94b5b16cb6952b8ef3ebbdc897696/href</a></iframe><p>Let take a closer look over the handleChange() event handler:</p><pre>handleChange(event) {   <br>   const target = event.target;<br>   const value = target.type === &quot;checkbox&quot; ?<br>                 target.checked :  <br>                 target.value;        <br>  const name = target.name;        <br>  const updatedFields = { ...this.state.fields };<br>  updatedFields[ name ] = value;<br>  this.setState({ ...this.state, fields: updatedFields });   <br>}</pre><p>The form component updates its inner fields state upon every change.<br>In this way — when the user submit the form, the fields set is already up-to-date with each field latest value.<br>All there left to do, is to construct a suitable dictionary/object, and send it away!</p><p>For future details and deeper implementation capabilities, you’re more than welcome to clone the source from:<br><a href="https://github.com/izikorgad/react-stateful-forms/">https://github.com/izikorgad/react-stateful-forms</a></p><p>Or just consume it as npm package from:<br><a href="https://www.npmjs.com/package/react-stateful-forms">https://www.npmjs.com/package/react-stateful-forms</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b3b708366f2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-redux-best-practice/writing-forms-in-react-1b3b708366f2">Writing Forms in React</a> was originally published in <a href="https://medium.com/react-redux-best-practice">react-redux-best-practice</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build Your First React Application In 15 Minutes]]></title>
            <link>https://medium.com/react-redux-best-practice/build-your-first-react-application-in-15-minutes-9ba4014a32ef?source=rss-1faa712b56f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ba4014a32ef</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[npm]]></category>
            <category><![CDATA[get-started]]></category>
            <category><![CDATA[single-page-applications]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Izik Orgad]]></dc:creator>
            <pubDate>Fri, 24 Nov 2017 11:42:05 GMT</pubDate>
            <atom:updated>2017-11-24T11:42:05.250Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*IUQImppS1UgrExV-8uY6yg.jpeg" /></figure><p>You might have heard on <a href="https://facebook.github.io/react/">React</a> or even saw some cool project examples, but can you imagine you’ll be able to build your own react-based application in nor more then 15 minutes? <br>Well… now you can!</p><h4>Prerequisites</h4><ol><li><strong>Basic </strong>knowledge in <a href="https://www.w3schools.com/Js/">JavaScript</a>.</li><li><a href="https://nodejs.org/en/">Node.js</a> installed.</li><li>Optional: Supported IDE (such as: <a href="https://code.visualstudio.com/">VS Code</a>, <a href="https://atom.io/">Atom</a>, <a href="https://www.jetbrains.com/webstorm/">WebStorm</a>, or any other alternative you’d like).</li></ol><p>The full source-code can be found on my Github: <a href="https://github.com/izikorgad/my-first-react-app">https://github.com/izikorgad/my-first-react-app</a></p><h4>Project Setup</h4><p>First, create a new directory — let’s call it ‘my-first-react-app’.<br>Now, open a new console/terminal from that new directory path and type the following command:</p><pre>npm init</pre><p>npm init is a command that trigger project-setup process, it will ask you a several questions during that process — you can just hit Enter and stick with the default properties (which is perfectly OK), ot specify your own values.</p><p>When npm init is complete, it will create a new file called “package.json”.<br>This file is basically our project file under npm framework (similar to .proj file on other frameworks).<br>Lets focus on the major sections:</p><ol><li>name: the name of your project/package.</li><li>scripts: each entry in this section will be a legal npm execution caomman.<br>For example, we can use the default ‘test’ script and run:</li></ol><pre>npm run test</pre><p>The result of the above execution would be:</p><pre>“Error: no test specified”</pre><p>Lets add our own new script entry: <em>“start”: “node .”</em></p><pre>“scripts”: {</pre><pre>“start”: “node .”,</pre><pre>“test”: “echo \”Error: no test specified\” &amp;&amp; exit 1&quot;</pre><pre>},</pre><p>3. dependencies: other npm packages that are required by your package (e.g. react)</p><p>4. devDependencies: npm packages that are needed for your development/build environment. Those package won’t be installed on your consumers during npm install command.</p><p>Now, lets add some basic requirements.<br>Execute the following command (note that the current shell path is your project directory):</p><pre><br>npm install --save react react-dom</pre><p>This will add react and react-dom as dependencies (the <em>-save</em> flag will also update your package.json)</p><h4>Transpilation &amp; Packing</h4><p><strong>Transpilation<br></strong>The JavaScript language is on a constant enhancement process.<br>JavaScript follows the <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">Ecma standard</a> which declares new features and capabilities on each new version.<br>Browsers</p><p>In order to be able to writ our code using the latest ES version (which will make our code cleaner and much more readable), but still function on any browser - we need to use a transpailer.<br>The most common transpailer is <a href="https://babeljs.io/">babel</a>.<br>Babel has a very wide and active community, that supplies many useful plugins framework.</p><p><strong>Packing<br> </strong>On the other hand, there is the packing phase: <br>A typical Javascript project contains multiple source files and many other resources (css, icons, fonts, etc.), which make the final application deployment to a painful process.</p><p>One of the most popular tools is<strong> </strong><a href="https://webpack.js.org/"><strong>webpack</strong></a>.<br>It allow us to run our application from a single (or several pre-defined) .js file.</p><p>Another very useful tool is <strong>webpack dev server</strong>, which enable us to decouple front-end development from web server implementation, by acting as local web-server that serves our single page application.<br>Webpack dev server watches our source file, so any change we’ll make will take affect immediately, without the tedious build+compile+run process.</p><p>So, for the next phase, let’s add all those necessary modules as dev-dependencies:</p><pre>npm install --sav-dev babel-core babel-loader babel-preset-es2015 babel-preset-react webpack webpack-dev-server</pre><p>Now, create a new folder named ‘config’ under your project root directory.<br>Under the new config folder create new file ‘webpack.config.js’:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d9bbbf62f99846a3cffb467b4b39687f/href">https://medium.com/media/d9bbbf62f99846a3cffb467b4b39687f/href</a></iframe><p>On the same directory create a new file called .babelrc (this is the babel configuration file):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f22067f8d49414ae51bb7cfd70d17b0/href">https://medium.com/media/2f22067f8d49414ae51bb7cfd70d17b0/href</a></iframe><p>One last thing, before we’ll start the real fun…<br>Change the npm script ‘start’ we’ve created eralier into:</p><pre>&quot;start&quot;: &quot;webpack-dev-server — config ./config/webpack.config.js — colors”</pre><h4>Single Page Application</h4><p>In a single page application we only <strong>one</strong> html file with almost zero content.<br>When this page (usually named index.html) is served, it asked for additional resources file from the server - on our case a single .js file.<br>Then, the real magic happens: our whole application, embedded in a single javascript file, starts to dynamically create new DMO elements and appending them into the single html file.<br>Basically- react uses this html as a sketch-board.</p><p>Create a new folder ‘src’ under the project root directory.<br>Just beneath it, create another one called ‘components’.<br>Add an index.html file under the root directory:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/665e10b0b8f88f0439981f5d842953bc/href">https://medium.com/media/665e10b0b8f88f0439981f5d842953bc/href</a></iframe><p>Your project should have the following structure by now:</p><pre>- my-firts-react-app<br>  - config<br>      webpake.config.json<br>      .babelrc<br>  - node_modules<br>  - src<br>    - components<br>  index.html<br>  package-lock.json<br>  package.json</pre><p>Now, create our starting point script index.js under the src directory (you can think of it as the ‘main’ in other languages):</p><pre>import React from &#39;react&#39;;<br>import ReactDOM from &#39;react-dom&#39;;<br>import App from &#39;components/app&#39;;</pre><pre>ReactDOM.render(&lt;App/&gt;, document.getElementById(&#39;app&#39;));</pre><p>As you can see, the code above just looks for a div with id=’app’ render new content &lt;App/&gt; within that element.<br>But, wait a second - what is this new &lt;App/&gt; HTML tag???<br>All react rendered elements are not html tags, they just looks alike, those are really <a href="https://reactjs.org/docs/jsx-in-depth.html">JSX Elements</a>.</p><p>The way to produce and render JSX we use React components.</p><h4>React Components</h4><p>React application is built from an hierarchy of well-defined components.<br>Each component acts as a single Lego part.</p><p>Let’s create our first and missing component - App:<br>Create new file under the ‘components’ folder named ‘app.jsx’:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/78a4383fcf29238fd30763697c69ab03/href">https://medium.com/media/78a4383fcf29238fd30763697c69ab03/href</a></iframe><p>Now, you can run your application by executing the npm script we’ve defined earlier:</p><pre>npm start</pre><p>Your application will be available on <a href="http://localhost:3000,">http://localhost:3000,</a> and should look like that:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*A3qPYDbuRbi_IkHySfVYMw.png" /><figcaption>Your first react app</figcaption></figure><p>all there left is to create and add new components to enrich your new application.</p><p>Enjoy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ba4014a32ef" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-redux-best-practice/build-your-first-react-application-in-15-minutes-9ba4014a32ef">Build Your First React Application In 15 Minutes</a> was originally published in <a href="https://medium.com/react-redux-best-practice">react-redux-best-practice</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Establishing Organizational npm Repository Over Nexus]]></title>
            <link>https://medium.com/react-redux-best-practice/establishing-private-npm-repository-over-nexus-7a45d9f1cf0d?source=rss-1faa712b56f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a45d9f1cf0d</guid>
            <category><![CDATA[build]]></category>
            <category><![CDATA[npm]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[repositories]]></category>
            <category><![CDATA[nexus]]></category>
            <dc:creator><![CDATA[Izik Orgad]]></dc:creator>
            <pubDate>Fri, 24 Mar 2017 07:02:27 GMT</pubDate>
            <atom:updated>2017-04-26T19:06:23.962Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Establishing Organizational npm Repository Over Nexus</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*mjkY-_ynf0qnWvqcFW3kDg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AagfZZ8bGOI4iTbLqewg6Q.png" /></figure><h4>Overview</h4><p>The <a href="https://www.npmjs.com/">npm</a> framework is a great engine for developing a variety of Node.js-based applications.</p><p>One of the greatest thing about npm, is the fact that it acts like an enormous registry, meaning: you can search for package , install the one you’d like, and publish your own packages out to the world.</p><p>This endless registry become more and more popular over the last years, and many organizations are using it as a important part of their code base.</p><p>However, been depended on an external registry can pose some major concerns when it comes to stability and code protection:</p><h4>Build Stability</h4><p>This is no secret that many of the available npm packages suffers from lake of stability and quality assurance. <br>This fact may be a minor issue for individuals or small organization, but for operating organizations this issue become a critical problem, due to their need to be able to keep their product versions/builds stable as it possible.</p><p>Moreover, event when an organization is able to produce a stable build - the consist publication stream to npm, raise a reasonable change for the next build to fail, regardless the actual change made on the core code base.</p><h4>Code Protection</h4><p>Another painful issue, is the ability to protect internal organizational IP (e.g. source code, data models, algorithms et cetera). <br>If we’ll choose to use the default public npm repository, all our published packages will be exposed to to the world. In case of front-end js/ts source code, the problem becomes even more urgent because the final artifacts are the actual source code or the transpiled code.</p><h4>The Solution: Private npm Repository</h4><p>In order to be able to preserve build stability, and protect important IP assets, but still enjoy all the benefits of npm global community, we should establish our own private organizational npm repository that will holds all out inner npm package.</p><blockquote>Note: we use the private repository as internal <em>npm registry</em>, do not confuse it with <em>source control management system</em>! this repo will holds our <strong>published</strong> packages, not their source!</blockquote><p>In this article, I’ll use <a href="http://www.sonatype.org/nexus/">Nexus</a> 3 as the npm internal registry. <br>Note that there are other solutions based different artifact servers.</p><h4>NPM Repository Setup</h4><p>Log in to your Nexus server, and click on <em>Create repository</em> button:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*8BvBx7yMxOCRpBEmQS6L6g.png" /><figcaption>Create new repository</figcaption></figure><p>Our solution configuration will be a combination of three Nexus repository types:</p><ol><li>npm hosted- for internal npm packaged kept on our Nexus server.</li><li>npm proxy- proxy repository to to the global npm registry.</li><li>npm group- a group of the two first repos.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/183/1*QTerMA8xrBp813gDx0KGWg.png" /><figcaption>npm repository types</figcaption></figure><p>First, create a new npm proxy repository:</p><ul><li>Set the “Name” filed to be npm-proxy (or any other name you’d like).</li><li>In the “Remote storage” set the url to: <a href="https://registry.npmjs.com/">https://registry.npmjs.com</a>.</li><li>Leave all other properties with their default values.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*fVRRVZ-MAOHOfYowRTK2TA.png" /><figcaption>npm-proxy repositort</figcaption></figure><p>Now, we’ll define the internal npm repository:</p><ul><li>Create new npm <strong>hosted</strong> repository.</li><li>Set the “Name” filed to be npm-internal (or any other name you’d like).</li><li>Leave all other properties with their default values.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*iuXuqQdykOf-YvBLzvHfgw.png" /><figcaption>npm hosted repository</figcaption></figure><p>The last repository is a group of the two repositories we’ve defined earlier:</p><ul><li>Create new npm <strong>group</strong> repository.</li><li>Set the “Name” filed to be npm-all (or any other name you’d like).</li><li>Add the two other npm repos as members.</li><li>Leave all other properties with their default values.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*upkkpI1USaMfv2a-KLH_OA.png" /><figcaption>npm group repository</figcaption></figure><h4>NPM Configuration</h4><p>Now, that we’ve established our own npm registry, all that left to do is to configure our local npm to work against this private registry.</p><ul><li>In your .npmrc file (should be located on your project root directory, if it’s not there- create in manually): add the following lines:</li></ul><p><em>registry=http://&lt;nexuse_server_address&gt;</em><a href="http://10.0.0.15:8081/repository/npm-all/"><em>/repository/npm-all/</em></a><em><br>_auth=&lt;your_auth_token&gt;</em></p><p>The auth token can be obtain by executing the following command:<br>echo -n ‘&lt;nexus_user_name&gt;:&lt;nexus_user_password&gt;’ | openssl base64</p><ul><li>In your packge.json add the following entry:<br>…<br>“publishConfig”: {<br> “registry”: “http://&lt;nexuse_server_address&gt;<a href="http://10.0.0.15:8081/repository/npm-all/">/repository</a><a href="http://il-poc-15:8080/repository/npm-internal/">/npm-internal/</a>&quot;<br> },<br>…</li></ul><blockquote>Due to our new configuration each “<strong>npm install</strong>” command will first check if the requested package was already downloaded to Nexus server, if so it will fetch it immediately, otherwise- the new package will be downloaded from the external global npm registry (using our proxy repository), and then will be served to the client.</blockquote><blockquote>Every “<strong>npm publish</strong>” command will publish the package directly to the internal repository, so it will not be exposed to the external world.</blockquote><h4>Summary</h4><p>In this article we’ve demonstrate how a private npm registry helps organizations to mange npm development but still keep their releases stabled and protect their code.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a45d9f1cf0d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/react-redux-best-practice/establishing-private-npm-repository-over-nexus-7a45d9f1cf0d">Establishing Organizational npm Repository Over Nexus</a> was originally published in <a href="https://medium.com/react-redux-best-practice">react-redux-best-practice</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>