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

browser-create-react-app example doesn't work with js-ipfs #1924

Closed
niinpatel opened this issue Mar 13, 2019 · 6 comments
Closed

browser-create-react-app example doesn't work with js-ipfs #1924

niinpatel opened this issue Mar 13, 2019 · 6 comments

Comments

@niinpatel
Copy link
Contributor

  • Version:
    js-ipfs version: 0.35.0-rc.0
  • Platform:
    Windows 10 64-bit
    Google Chrome Version 73.0.3683.75
  • Subsystem: js-ipfs

Type: bug

Severity: Low

Description:

I tried to run the example implementation from examples/browser-create-react-app.

It only works correctly when go-ipfs daemon is running. Here's a preview when go-ipfs node is running in the computer.

image

But when I run js-ipfs instead of go-ipfs, it fails:

js-ipfs-react-not-working

Steps to reproduce the error:

Step 1: run the js-ipfs daemon
Step 2: cd into examples/create-react-app and run npm install && npm start

@alanshaw
Copy link
Member

Looks like you're using IPFS Companion - was companion connected to the JS IPFS node when you tried this? Companion shouldn't be injecting window.ipfs if it doesn't have a connection to a node... @lidel have you seen this before?

@niinpatel
Copy link
Contributor Author

niinpatel commented Mar 13, 2019

@alanshaw, I just realized it happened because IPFS companion was there but not connected to the js-ipfs node. If I remove the chrome extension, it works fine. IPFS companion was probably injecting its own window.ipfs in this.

@lidel
Copy link
Member

lidel commented Mar 13, 2019

@alanshaw I am afraid that in Chrome window.ipfs is always injected.
This is due to ipfs/ipfs-companion#362 (comment)

I hope this behavior will go away with ipfs/ipfs-companion#589 - after move to async API and removal of window.ipfs we won't need the guarantee of being the first script on the page. I plan to remove hardcoded content scripts responsible for injection from the manifest, and do it programmatically like in Firefox.

Question: should we prioritize this and remove it earlier? I believe it should be fairly safe (In Chrome window.ipfs will be missing, so some fallback will kick in)

@alanshaw
Copy link
Member

Ah yes I remember now!

@kuabhish
Copy link

kuabhish commented Apr 17, 2020

Hey @alanshaw @lidel

I do not understand this problem .. and solution..

I was working on windows ..ad i could add the files and view them somehow..

but as i am in ubuntu now --and I see that ..

  1. I am able to add file from running a normal script. like node.add ()..
  2. and able to fetch it

but

  1. not able to fetch anything if i do the same thing with a react app. (which i could do in windows ..)

and also i am not able to run this example repo.. browser-create-react-app

and In windows .. i could do everything without starting daemon ..

So, Please help me understand the issue. and solution ..

@lidel
Copy link
Member

lidel commented Apr 21, 2020

@kuabhish I don't believe problems you experience are related to this issue.
IPFS Companion v2.11 is not injecting window.ipfs at the moment.

Please create new issue and provide more details about your setup and what you want to accomplish.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants