Notice
This repository is unmaintained due to my lack of time and due to not keeping up with Gun or using it in any of my projects.
React Gun
Simple Higher-Order Component for GunDB in React
Installation
Install with yarn
or npm
yarn add react-gun
Initialize GunProvider to make your Gun() object available to any component...
App.js
;;; const App = { // Initialize all your app stuff let gun = ; return <GunProvider gun=gun> <ComponentThatUsesGun /> </GunProvider> ;};;
Then call your gun instance by wrapping your component with {withGun}
like so
Component.js
;; state = foo: null ; { // Get objects from Gun() instance and use it to update state or do whatever else you'd like with it thispropsgun; } { if !thisstatefoo return <div>Loading...</div>; return <div>thisstatefoo</div>; } ComponentThatUsesGun;