Rendering a function with React – kentcdodds

  • But there are reasons for the API as it is and that’s not what we’re going over in this newsletter…With ReactSo thinking about this in the context of React:const getHomeContent = getContent(‘pages.home’)const ui = ( a href=”/about” {getHomeContent(‘nav.about’)} /a)// that’ll get you:a href=”/about”About/aSo far so good.
  • Anyway, this will break the app:const getHomeContent = getContent(‘pages.typo’)const ui = ( a href=”/about” {getHomeContent(‘nav.about’)} /a)// 💥 error 💥Again, this is happening because getContent(‘pages.typo’) will return the string {pages.typo} (to indicate that there’s no content at that path and the developer needs to fix that problem to get the content)….
  • The issue is that you can’t invoke a string but that’s what’s happening because getHomeContent is a string, not a function.A solution and a new problemSo the change I made this week makes it so when there’s no content at a given path, instead of a string, it returns a “sorta-curried”…
  • No problem.So now this wont throw an error, but we lose rendering the path if there’s no content!const getHomeContent = getContent(‘pages.typo’)const ui = ( a href=”/about” {getHomeContent(‘nav.about’)} /a)// that’ll get you:a href=”/about”/aAnd we want to make sure that we show the missing content so it’s more obvious for developers (yes…
  • Let’s rewrite the above to make this more clear:const getHomeContent = getContent(‘pages.typo’)const aboutContent = ui = a in this example is a function because the call to getContent had a typo, so we’ll never actually find content that matches the full path.

NOTE: This is a cross-post from my newsletter. I publish each email two weeks after it’s sent. Subscribe to get more content like this earlier right in your inbox! 💌 This week I was working on an…
Continue reading “Rendering a function with React – kentcdodds”

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”

Do you think Ionic or React Native can ever replace the Java SDK in Android?

Can #ionic or #ReactNative ever replace the Java SDK in #Android?

  • Not fully replace, but if you are a js developer of have a team of js developers is interesting to have 1 language to make the forntend web, and the app mobile 🙂
  • It’s not designed with complex 3D games in mind, which might be possible with Java.
  • At the stage product rebuild again, with native technology’s.
  • My opinion is that V8 never replace the Java SDK regarding mobile contexts.
  • The low-level Android Java SDK is for max.

I saw demo apps made by ionic and react native.. not bad but can never be compared to java apps..but what about the future? Can we ever dream of a fully f. Tagged with Android,iOS,Ionic,React Native.
Continue reading “Do you think Ionic or React Native can ever replace the Java SDK in Android?”

Top 8 Most Popular JavaScript FrameworksJscrambler Blog

What are the 8 Most Popular #JavaScript Frameworks? Find out:  #webdev #angularjs #reactjs

  • The framework offers structure so you can build custom HTML elements using browser-based technologies like Web Components, so the developer could use different name schemes.
  • It may be worth for you to give a try on the framework, but with some caution so every component works on different browsers.
  • Looking on the bright side, the framework has a nice active community of developers, so you won’t be that lost in the process of adapting your project.
  • Launched by Google in 2009 and available as open source under MIT license, Angular is one of the favorites JavaScript framework for developing single page web applications.
  • Also known and called as a game engine, Babylon.js is an open source framework that’s been on the market since 2013.

Read the full article, click here.


@Jscrambler: “What are the 8 Most Popular #JavaScript Frameworks? Find out: #webdev #angularjs #reactjs”


Take a look at the 8 most popular JavaScript frameworks available today and compare each one of them regarding its advantages and disadvantages.


Top 8 Most Popular JavaScript FrameworksJscrambler Blog