diff --git a/examples/browser-create-react-app/public/manifest.json b/examples/browser-create-react-app/public/manifest.json index 1f2f141faf..5845b822ec 100755 --- a/examples/browser-create-react-app/public/manifest.json +++ b/examples/browser-create-react-app/public/manifest.json @@ -1,6 +1,6 @@ { - "short_name": "React App", - "name": "Create React App Sample", + "short_name": "IPFS React App", + "name": "IPFS Create React App Example", "icons": [ { "src": "favicon.ico", diff --git a/examples/browser-create-react-app/src/App.js b/examples/browser-create-react-app/src/App.js index 4503df4cd1..8d8a20d483 100755 --- a/examples/browser-create-react-app/src/App.js +++ b/examples/browser-create-react-app/src/App.js @@ -4,15 +4,15 @@ import useIpfs from './hooks/use-ipfs.js' import logo from './ipfs-logo.svg' const App = () => { - const { ipfs, ipfsInitError } = useIpfsFactory({commands: ['id']}) + const { ipfs, ipfsInitError } = useIpfsFactory({ commands: ['id'] }) const id = useIpfs(ipfs, 'id') return (
-
- - IPFS logo +
+ + IPFS logo -

IPFS React

+

IPFS React

{ipfsInitError && ( @@ -26,20 +26,20 @@ const App = () => { ) } -const Title = ({children}) => { +const Title = ({ children }) => { return ( -

{children}

+

{children}

) } const IpfsId = (props) => { - if (!props) return null + if (!props) return null return (

Connected to IPFS

{['id', 'agentVersion'].map((key) => ( -
+
{key}
{props[key]}
diff --git a/examples/browser-create-react-app/src/App.test.js b/examples/browser-create-react-app/src/App.test.js index e978da7f5c..4bf19359ea 100755 --- a/examples/browser-create-react-app/src/App.test.js +++ b/examples/browser-create-react-app/src/App.test.js @@ -6,4 +6,4 @@ it('renders without crashing', () => { const div = document.createElement('div') ReactDOM.render(, div) ReactDOM.unmountComponentAtNode(div) -}); +}) diff --git a/examples/browser-create-react-app/src/hooks/use-ipfs-factory.js b/examples/browser-create-react-app/src/hooks/use-ipfs-factory.js index fd992f8352..acdf8ee856 100644 --- a/examples/browser-create-react-app/src/hooks/use-ipfs-factory.js +++ b/examples/browser-create-react-app/src/hooks/use-ipfs-factory.js @@ -13,8 +13,8 @@ let ipfs = null * so use-ipfs calls can grab it from there rather than expecting * it to be passed in. */ -export default function useIpfsFactory ({commands}) { - const [isIpfsReady, setIpfsReady] = useState(!!ipfs) +export default function useIpfsFactory ({ commands }) { + const [isIpfsReady, setIpfsReady] = useState(Boolean(ipfs)) const [ipfsInitError, setIpfsInitError] = useState(null) useEffect(() => { @@ -34,11 +34,9 @@ export default function useIpfsFactory ({commands}) { async function startIpfs () { if (ipfs) { console.log('IPFS already started') - } else if (window.ipfs && window.ipfs.enable) { console.log('Found window.ipfs') - ipfs = await window.ipfs.enable({commands}) - + ipfs = await window.ipfs.enable({ commands }) } else { try { console.time('IPFS Started') @@ -51,10 +49,10 @@ export default function useIpfsFactory ({commands}) { } } - setIpfsReady(!!ipfs) + setIpfsReady(Boolean(ipfs)) } - return {ipfs, isIpfsReady, ipfsInitError} + return { ipfs, isIpfsReady, ipfsInitError } } function promiseMeJsIpfs (Ipfs, opts) {