Structuring React Projects

Structuring React Projects —

  • Our Kanban application has a somewhat flat structure: – – It’s enough for this purpose, but there are some interesting alternatives around: – – There are more alternatives but these cover some of the common cases.
  • This setup isn’t enough when you want to add multiple views to the application.
  • You could have separate views for the home page of the application, registration, Kanban board, and so on, matching each route.
  • One way to deal with routing is to push it to a component that coordinates which view is displayed at any given time based on the current route.
  • It could be natural to introduce a concept, such as “feature”, between the views and the components.

React doesn’t enforce any particular project structure. The good thing about this is that it allows you to make up a structure to suit your needs. The bad thing is that it is not possible to provide you an ideal structure that would work for every project. Instead, I’m going to give you some inspiration you can use to think about structure.
Continue reading “Structuring React Projects”

How to make Jenkins build NodeJS, Ruby, and Maven on Docker

How To Make Jenkins Build #NodeJS, #Ruby, And #Maven On #Docker  #reactjs #devops

  • Jenkins can speed up repetitive tasks that robots are much better performing and Docker simplifies spinning up VM’s for your application in a very simple and repeatable way.
  • What I’m going to cover here is how to setup your Jenkins server in a Docker container and how to fix some of the limits of the Jenkins official image.
  • While it is nice of Jenkins to offer an official docker image, you’ll quickly run into a few issues if you are doing anything even slightly other than compiling plain Java.
  • For instance, Maven, the popular dependency management tool for Java, is not included in the Docker container.
  • You’ve learned to create a Jenkins Docker-container that’s ready to run jobs for Java, Ruby and NodeJS projects.

Setup your Jenkins server in a Docker container and fix some of the limits of the official image I discovered so you can get up and building faster.
Continue reading “How to make Jenkins build NodeJS, Ruby, and Maven on Docker”

How to make Jenkins build NodeJS, Ruby, and Maven on Docker

How To Make Jenkins Build #NodeJS, #Ruby, And #Maven On #Docker  #reactjs #devops

  • Jenkins can speed up repetitive tasks that robots are much better performing and Docker simplifies spinning up VM’s for your application in a very simple and repeatable way.
  • What I’m going to cover here is how to setup your Jenkins server in a Docker container and how to fix some of the limits of the Jenkins official image.
  • While it is nice of Jenkins to offer an official docker image, you’ll quickly run into a few issues if you are doing anything even slightly other than compiling plain Java.
  • For instance, Maven, the popular dependency management tool for Java, is not included in the Docker container.
  • You’ve learned to create a Jenkins Docker-container that’s ready to run jobs for Java, Ruby and NodeJS projects.

Setup your Jenkins server in a Docker container and fix some of the limits of the official image I discovered so you can get up and building faster.
Continue reading “How to make Jenkins build NodeJS, Ruby, and Maven on Docker”

Some tips for getting started with React – DailyJS – Medium

Some tips for getting started with #React – DailyJS – Medium  #ReactJs

  • I initially spent an equal amount of time looking at Angular, Aurelia, React and Vue… but eventually settled on React.This isn’t to say that I think that React is “better” just that it was the best fit for my specific requirements.I’m a great believer in using the right tool for the job, you may have the best hammer in the world — but you shouldn’t try to use it to screw something together.React is a mature library so many best practices have been established, however I found that I didn’t fall into them immediately and had to learn them the hard way.If you’re a newcomer to React (and bear in mind that I’m no expert) you may find this advice useful…Start with “create-react-app”When I started out in the world of Node.js / npm based development I began by building a development environment from scratch.Whilst this was a valuable learning exercise I later found that not only did the “create-react-app” project provide a great starting point but the awesome comments throughout the “react-scripts” project (that you can browse in your node_modules folder or gain access to through ejecting) were incredibly informative.You might find that you don’t keep using it in the long term, but as a playground for getting up and running with React to learn it I don’t think it can be beaten.Keep reading the Official DocumentationThere are loads of great articles, tutorials and blogs out there but I’ve found myself repeatedly going back to the official docs.
  • Fortunately the error messages in React are exceptionally good and lead me straight back to the right page in the documentation that explained and solved the problem.Set state with a function, not an objectI’ve seen this recently in blogs and tweets.
  • Although it’s not caused me any problems I’m learning my lesson from the previous example and will update my code now to avoid issues in the future.Pick the right editorI’d been a Sublime Text user for years and still absolutely love it.
  • I still use Sublime Text for other JavaScript projects (just as I use Eclipse for Java projects) but Visual Studio works for me… as I wrote earlier, always pick the right tool for the job.Learn the Life CycleI’ve found that when creating React components I need to think differently about how to approach problems and that understanding the component life-cycle really helps find the solutions.One really valuable tip I’ve found is to make sure that if a component needs to derive state from props then you need to process those props in both the constructor and componentWillReceiveProps (especially when the component is going to be receiving new properties from its ancestors) as this has caught me out on more than one occasion.I would certainly recommend working through problems more than once (and a good set of unit tests can really help here) as switching my way of thinking from an object-oriented approach to a functional composition approach can be quite challenging at first.
  • I don’t expect them to be revelatory to anyone with a great deal of React experience but it was valuable to me to think about and log what I’ve learned over the past few months.If you have any feedback or suggestions for other good practices then please let me know!

I’ve been developing web applications for many years but until recently was constrained to developing on (and for) a Java stack that had to support old versions of Internet Explorer. This left me…
Continue reading “Some tips for getting started with React – DailyJS – Medium”

elm-calendar-react-storybook/app at master · kalutheo/elm-calendar-react-storybook · GitHub

#ReactJS storybook and #elmlang. Okay that's interesting :) 
See:

  • The project was bootstrapped with Create Elm App .
  • elm-app package install < package-name >
  • To use JavaScript packages from npm, you’ll need to add a package.json , install the dependencies and you’re ready to go.
  • Use it for installing Elm packages from package.elm-lang.org
  • Runs the app in the development mode.

elm-calendar-react-storybook – Simple demo of how ReactStoryBook can be used with an Elm App
Continue reading “elm-calendar-react-storybook/app at master · kalutheo/elm-calendar-react-storybook · GitHub”

Page object for testing React.js components – Medium

  • Let’s add one more test on handling submit.
  • Our test code encourages to do everything through Page object.
  • Page object wrapper gives you nice API to interact with your component, so test code will be more expressive and neat.
  • I also work a lot on developer infrastructure, especially in terms of testing.
  • We don’t test the whole web page, only one component, but we can think that our component is actually a little page, that we are going to interact with.

Today I will tell you a little trick how to make your test code a bit fancier and easier to maintain. The PageObject pattern is quite…
Continue reading “Page object for testing React.js components – Medium”

Testing your React components with Jest snapshots

Test your react components with Jest snapshots:  by @thibaut_cheymol #reactjs #JavaScript

  • Test your react components with Jest snapshots
  • describe ( ‘ Our first snapshot test ‘ , () => { it ( ‘ Should compare the component with a snapshot ‘ , () => { const component = ‘
    Hello Jest

    ‘ expect ( component ) .

  • As we already have unit tests set up, we are going to test our first component right now.
  • Component snapshot tests are unit tests, so they are really fast, but they test your component behaviour.
  • import React , { Component } from ‘ react ‘ ; import ‘ ..

Test ReactJS and React Native components with Jest snapshots
Continue reading “Testing your React components with Jest snapshots”