Superheroes: Import Error in CRUD + React, using dfx 0.8.4

Hi all,

Beginner here.

I’m trying to get this repo from Enzo working on my machine.

https://github.com/enzoh/superheroes

It’s a basic CRUD + React app, which is great for getting started, but it looks like it was built using dfx 0.6.4, and I’m on dfx 0.8.4.

I don’t know if that’s the problem, though.

Last commit was Sept. 1, 2020, so I’m guessing a lot has changed.

After successfully running

npm install
dfx start
dfx canister create --all

I am trying

dfx build

and running into an errors.

I fixed one error by changing this line:

https://github.com/enzoh/superheroes/blob/master/src/superheroes/Main.mo#L20

public type SuperheroId = Word32;

to

public type SuperheroId = Nat32;

Guessing that’s a change in Motoko.

After that, I am getting another error in each of the CRUD components on this import:

https://github.com/enzoh/superheroes/blob/master/src/www/components/create.jsx#L10

import Superheroes from 'ic:canisters/superheroes';

    ERROR in ./src/www/components/create.jsx
    Module not found: Error: Can't resolve 'ic:canisters/superheroes' in '/Users/steve/projects/ic/superheroes/src/www/components'
     @ ./src/www/components/create.jsx 9:0-51 25:4-15
     @ ./src/www/index.jsx

If anyone is familiar with this app, or recognizes that sort of import error, generally, and has any ideas, I would be most appreciative!

Thanks,

Steve

EDIT:

FWIW, I’m guessing this has something to with this:

https://smartcontracts.org/docs/release-notes/0.8.0-rn.html#_instructions_on_migrating_to_dfx_0_8_0

Seems there are a lot of changes in dfx 0.8.0 vs older versions to do with Candid, declarations, etc.

I wonder if it’s better to start with a different template for integrating with React.

I’m currently looking at this from Kyle:

https://github.com/krpeacock/dfx-template-react