Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Commit 3843f47

Browse files
niinpatelAlan Shaw
authored and
Alan Shaw
committed
docs: fix formatting in examples/create-react-app (#1943)
License: MIT Signed-off-by: Nitin Patel <[email protected]>
1 parent 5bad666 commit 3843f47

File tree

4 files changed

+17
-19
lines changed

4 files changed

+17
-19
lines changed

browser-create-react-app/public/manifest.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"short_name": "React App",
3-
"name": "Create React App Sample",
2+
"short_name": "IPFS React App",
3+
"name": "IPFS Create React App Example",
44
"icons": [
55
{
66
"src": "favicon.ico",

browser-create-react-app/src/App.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import useIpfs from './hooks/use-ipfs.js'
44
import logo from './ipfs-logo.svg'
55

66
const App = () => {
7-
const { ipfs, ipfsInitError } = useIpfsFactory({commands: ['id']})
7+
const { ipfs, ipfsInitError } = useIpfsFactory({ commands: ['id'] })
88
const id = useIpfs(ipfs, 'id')
99
return (
1010
<div className='sans-serif'>
11-
<header className="flex items-center pa3 bg-navy bb bw3 b--aqua">
12-
<a href="https://ipfs.io" title="home">
13-
<img alt="IPFS logo" src={logo} style={{ height: 50 }} className='v-top' />
11+
<header className='flex items-center pa3 bg-navy bb bw3 b--aqua'>
12+
<a href='https://ipfs.io' title='home'>
13+
<img alt='IPFS logo' src={logo} style={{ height: 50 }} className='v-top' />
1414
</a>
15-
<h1 className="flex-auto ma0 tr f3 fw2 montserrat aqua">IPFS React</h1>
15+
<h1 className='flex-auto ma0 tr f3 fw2 montserrat aqua'>IPFS React</h1>
1616
</header>
1717
<main>
1818
{ipfsInitError && (
@@ -26,20 +26,20 @@ const App = () => {
2626
)
2727
}
2828

29-
const Title = ({children}) => {
29+
const Title = ({ children }) => {
3030
return (
31-
<h2 className="f5 ma0 pb2 tracked aqua fw4 montserrat">{children}</h2>
31+
<h2 className='f5 ma0 pb2 tracked aqua fw4 montserrat'>{children}</h2>
3232
)
3333
}
3434

3535
const IpfsId = (props) => {
36-
if (!props) return null
36+
if (!props) return null
3737
return (
3838
<section className='bg-snow mw7 center mt5'>
3939
<h1 className='f3 fw4 ma0 pv3 aqua montserrat tc'>Connected to IPFS</h1>
4040
<div className='pa4'>
4141
{['id', 'agentVersion'].map((key) => (
42-
<div className="mb4" key={key}>
42+
<div className='mb4' key={key}>
4343
<Title>{key}</Title>
4444
<div className='bg-white pa2 br2 truncate monospace'>{props[key]}</div>
4545
</div>

browser-create-react-app/src/App.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ it('renders without crashing', () => {
66
const div = document.createElement('div')
77
ReactDOM.render(<App />, div)
88
ReactDOM.unmountComponentAtNode(div)
9-
});
9+
})

browser-create-react-app/src/hooks/use-ipfs-factory.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ let ipfs = null
1313
* so use-ipfs calls can grab it from there rather than expecting
1414
* it to be passed in.
1515
*/
16-
export default function useIpfsFactory ({commands}) {
17-
const [isIpfsReady, setIpfsReady] = useState(!!ipfs)
16+
export default function useIpfsFactory ({ commands }) {
17+
const [isIpfsReady, setIpfsReady] = useState(Boolean(ipfs))
1818
const [ipfsInitError, setIpfsInitError] = useState(null)
1919

2020
useEffect(() => {
@@ -34,11 +34,9 @@ export default function useIpfsFactory ({commands}) {
3434
async function startIpfs () {
3535
if (ipfs) {
3636
console.log('IPFS already started')
37-
3837
} else if (window.ipfs && window.ipfs.enable) {
3938
console.log('Found window.ipfs')
40-
ipfs = await window.ipfs.enable({commands})
41-
39+
ipfs = await window.ipfs.enable({ commands })
4240
} else {
4341
try {
4442
console.time('IPFS Started')
@@ -51,10 +49,10 @@ export default function useIpfsFactory ({commands}) {
5149
}
5250
}
5351

54-
setIpfsReady(!!ipfs)
52+
setIpfsReady(Boolean(ipfs))
5553
}
5654

57-
return {ipfs, isIpfsReady, ipfsInitError}
55+
return { ipfs, isIpfsReady, ipfsInitError }
5856
}
5957

6058
function promiseMeJsIpfs (Ipfs, opts) {

0 commit comments

Comments
 (0)