reactions/component by ryanflorence #javascript #reactjs via JavaScriptKicks

  • Because sometimes you want a lifecycle or some state but don’t want to create a new component.
  • And then import it: – – Or use script tags and globals.
  • And then grab it off the global like so: – – Let’s say you want some async data but don’t want to make a whole new component just for the lifecycles to get it: – – Or maybe you need a little bit of state but an entire component seems…

GitHub is where people build software. More than 27 million people use GitHub to discover, fork, and contribute to over 80 million projects.

We recommend upgrading to the latest Safari, Google Chrome, or Firefox.

GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.

If nothing happens, download the GitHub extension for Visual Studio and try again.

Declarative version of React.Component.

Because sometimes you want a lifecycle or some state but don’t want to create a new component. Also, this stuff is composable as heck.

And then import it:

Or use script tags and globals.

And then grab it off the global like so:

Let’s say you want some async data but don’t want to make a whole new component just for the lifecycles to get it:

// import Component from ‘@reactions/component’ const Component = ReactComponentComponent; ReactDOM.render(

Let’s get some gists!

{ fetch(“https://api.github.com/gists”) .then(res => res.json()) .then(gists => setState({ gists })); }} > {({ state }) => state.gists ? (

    {state.gists.map(gist => (

  • {gist.description}
  • ))}

) : (

Loading…

) }

, DOM_NODE );

Or maybe you need a little bit of state but an entire component seems a bit heavy:

// import Component from ‘@reactions/component’ const Component = ReactComponentComponent; ReactDOM.render( {({ setState, state }) => (

Every app needs a counter!

GitHub