Improving the usability of your modules – kentcdodds

Improving the usability of your modules  #reactjs

  • All you have to do is use it:import getContentForFile from ‘react-i18n’const i18n = App() { return ( div h1{i18n(‘header.title’)}/h1 /div )}So that’s how it works (again, I’m sure some of you are thinking of other libs that could do this better, but please spare me the “well actually.” I’m aware…
  • const content = JSON.parse( … more stuffexport {getContentForFile as default, init}This presents a few challenges for users of the module.
  • Turns out that react-i18n actually exposed another module react-i18n/bootstrap to customize this behavior which is great, but that doesn’t resolve the problem of stuff happening if someone were to import react-i18n first.So what I did was a wrapped all side-effects in a function I exported called init(which was similar to…
  • But it’s ok now because that’s clear const messages = JSON.parse( ) // … other other stuff}// … more stuffexport {getContentForFile as default, init}So this means that anyone using the module now must call the init function, but they’re doing that on their own terms and whenever they want it…
  • However, we’re in the process of “inner sourcing” this module (and perhaps open sourcing it eventually), so folks are going to use it who use different tools and have different use cases.So, if it’s not too much work and doesn’t add too much complexity, then try to make the solution…

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 last week I worked on my…
Continue reading “Improving the usability of your modules – kentcdodds”

contra/react-responsive — Media queries in react for responsive design #reactjs

 — Media queries in react for responsive design 


  • For a list of all possible shorthands and value types see numbers given as a shorthand will be expanded to px ( will become )

    You may also specify a function for the child of the MediaQuery component.

  • When the component renders, it is passed whether or not the given media query matches.
  • You may specify an optional property on the that indicates what component to wrap children with.
  • If the property is not defined and the has more than 1 child, a will be used as the “wrapper” component by default.
  • The values property can contain , , , , , , , , , , , and to be matched against the media query.

react-responsive – Media queries in react for responsive design
Continue reading “contra/react-responsive
— Media queries in react for responsive design