All You Need To Know About CSS-in-JS – Hacker Noon

  • CSS-in-JS attached a style tag on top of the DOM while inline styles just attached the properties to the DOM node.Why does this matter?Not all CSS features can be aliased with JavaScript event handlers , many pseudo selectors aren’t possible, styling the html and body tags isn’t supported etc.With CSS-in-JS, you…
  • Some libraries (like jss, styled-components) even add support for neat, non-CSS-native features like nesting!Brilliant article going in depth on how they’re different.“Just write the darn CSS in CSS and be done with it.”Yes — while that’s the case for how it’s been done for a long-long time — the challenge is modern web is…
  • Shout-out to Vue for solving this problem beautifully even tho Vues styles have no access to components state.Here’s Bob Ross painting rocks to cool down the tension 😄What are the benefits of using CSS-in-JS?
  • CSS-in-JS leverages the full power of the JavaScript ecosystem to enhance CSS.“True rules isolation” — Scoped selectors are not enough.
  • JSS generates unique class names by default when it compiles JSON representation to CSS.Vendor Prefixing —The CSS rules are automatically vendor prefixed, so you don’t have to think about it.Code sharing — Easily share constants and functions between JS and CSS.Only the styles which are currently in use on your screen are…

TL;DR: Thinking in components — No longer do you have to maintain bunch of style-sheets. CSS-in-JS abstracts the CSS model to the component level, rather than the document level (modularity). You…
Continue reading “All You Need To Know About CSS-in-JS – Hacker Noon”

4 Key Concepts to Learning ReactJS

4 Key Concepts to Learning #ReactJS  #React #javascript #webdevelopment #coding

  • Aptly named Create-React-App, the tool scaffolds the file structure for your React app and includes a dev server, as well as a compiler, bundler, and more.
  • With so much to learn already in this library, not having to worry about your boilerplate code is a giant relief and the file structure that the CLI tool provides on install will give you everything you need to dive into creating your Dream App™.
  • They allow you to take methods, variables, and even state objects (another ReactJS feature) and pass them around to different parts of your application as PROPerties.
  • Most web apps use one database to store application state and best practice indicates that React state is treated much the same.
  • PropTypes are a way for you to tell your application what type of data your component should expect to be passed to it.

At Modus Create, our culture is defined by a few key objectives, including the value we place on constant learning and sharing of knowledge. It’s no surprise that when I’m not writing automation tests for a client, I am working on personal projects. With most development projects, there comes a time to decide what tools you want to build your UI with. For my latest project, I decided I wanted to use the React library. The only problem was…I didn’t know React — so I decided to see how far I could get using the resources at my disposal.
Continue reading “4 Key Concepts to Learning ReactJS”

Impress Your Friends With Code Splitting in React – Hacker Noon

Impress Your Friends With #Code Splitting in #ReactJS:  by @burkeholland #JavaScript

  • Both of those actions show the edit form.First I am going to add a spot in my state for this “EditForm” component to live.class Heroes extends Component { constructor(props) { super(props); this.state = { …, lazyEditHero: null } } …, render() { return ( … ) }}I put mine in…
  • I have put this in a function called LoadEditFormclass Heroes extends Component { constructor(props) { super(props); this.state = { … lazyEditHero: null } } async LoadEditForm() { const { default : EditHero } = await import(‘.
  • /EditHero’); this.setState({ lazyEditHero: EditHero }) } render() { return ( … ) }}Now we just need to call this LoadEditForm from the two functions that trigger the editor component to be shown.class Heroes extends Component { constructor(props) { super(props); this.state = { … lazyEditHero: null } } async LoadEditForm() {…
  • /EditHero’); this.setState({ lazyEditHero: EditHero }) } handleSelect = async hero = { await this.LoadEditForm(); this.setState({ selectedHero: hero }); } handleEnableAddMode = async () = { await this.LoadEditForm(); this.setState({ addingHero: true, selectedHero: { id: ”, name: ”, saying: ” } }); } … render() { return ( … ) }}A few…
  • This also allows us to pass any props to our component when it is so lazily loaded.class Heroes extends Component { constructor(props) { super(props); this.state = { … lazyEditHero: null } } async LoadEditForm() { const { default : EditHero } = await import(‘.

In preparation for the DevUp keynote a few weeks ago, I took some time to learn the minimum amount possible to demonstrate code splitting in React. Now your first reaction is probably… As part of the…
Continue reading “Impress Your Friends With Code Splitting in React – Hacker Noon”

Typescript or Flow – Product at Home

#Typescript or #Flow: What’s your type?  #ReactJS

  • If you spend your days making 100-line apps or scripting stuff in a console, maybe adding types is not the thing for you.But if you’re working on bigger apps or libraries, spending a couple of hours to set up and learn the basics of TS or Flow will bring you…
  • You end up with a more robust and reliable code base.What really matters for you as a developer is the final outputI see a lot of guides, sometimes really good ones, focussed on the structural and implementation differences between TS and Flow — TS is a language, Flow isn’t etc. — but these aren’t the…
  • Let’s see what warnings TS and Flow are giving me:Typescript error messageFlow error messageTypescript clearly gives us the solution to fix the problem, whereas Flow just flags a type incompatibility.Errors on missing propsFor me this one is the biggest issues with Flow: Instead of having the error in the Title / component like…
  • Better yet, I could avoid this problem altogether in TS by taking advantage of with Atom and VS Code are fine, but from personal experience, Typescript remains faster than Flow, especially on large projects.So it looks like Typescript is clearly the best choice, or is it?Setup:If you have an existing project…
  • You’ll still need your unit and e2e tests to be sure that your app is running as expected.Both Flow and Typescript are awesome ❤ and I’m really happy that both of these solutions exist.

tldr; You’re not a machine. You just can’t catch all bugs and know your (and your team’s) code by heart and it’s not your job. So add static types! Ok, let’s clarify something here. If you spend your…
Continue reading “Typescript or Flow – Product at Home”

safe-nightwatch – Demo of SAFE-Stack applied to React Native for cross platform native mo…

  • This is a demo application for React Native development in F# using Fable and the SAFE stack.
  • SAFE is a technology stack that brings together several technologies into a single, coherent stack for typesafe, flexible end-to-end web-enabled applications that are written entirely in F#.
  • If you want to try it out then please do the following: – – Make sure that the FSharp compiler is properly installed on your operating system: – – This could look like: – – If you run and it compiles everything, but nothing happens… go to the packager output…
  • If the above does not work, and still nothing happens after it compiles everything, the licenses may need to be accepted on your computer.
  • To accept the licenses run the following commands for your platform – – On a Mac run the following – – On Windows run the following – – Re-run the build script and everything should work.

SAFE-Nightwatch – Demo of SAFE-Stack applied to React Native for cross platform native mobile apps
Continue reading “safe-nightwatch – Demo of SAFE-Stack applied to React Native for cross platform native mo…”

Things to like in @stenciljs: – Compiles to #WebComponents – #TypeScript by default – JSX familiar to #Reactjs devs

  • The extension is required since Stencil components are built using JSX and TypeScript.
  • Here is an example of what a Stencil component looks like:

    Once compiled, this component can be used in HTML just like any other tag.

  • This decorator provides metadata about our component to the Stencil compiler.
  • This decorator tells the compiler that the property is public to the component, and the user should be setting it.
  • If a user of our component were to change the element’s property, our component would fire it’s function again, updating the displayed content.

Stencil components are created by adding a new file with a .tsx extension, such as my-first-component.tsx, and placing them in the src/components directory.
The .tsx extension is required since Stencil components are built using JSX and TypeScript.
Continue reading “Things to like in @stenciljs:
– Compiles to #WebComponents
– #TypeScript by default
– JSX familiar to #Reactjs devs”

What is React – Trey Davis – Medium

What is React  #programming #javascript #react #reactjs

  • React breaks web elements down into re-usable components making it easy to manage complex web interfaces.React’s virtual DOM makes rendering updates fast and efficient.
  • The Virtual DOM is a JavaScript representation of the actual DOM.
  • When updates are made React compares the current DOM to the virtual DOM and only updates the differences between the two.React uses declarative JSX which is an HTML-style syntax inside of JavaScript.
  • React components can be reused and declared using JSX.
  • The Babel compiler converts JSX to JavaScript which renders the HTML view.React handles the majority of DOM rendering, so your index.html file begins as a simple div where React will append the DOM elements.Next we’ll walk through making a React component.

React is a fast, component-based, front-end JavaScript library. React typically runs in your browser and renders single-page web application user interfaces (and thanks to React-Native, mobile…
Continue reading “What is React – Trey Davis – Medium”