DEV Community

Discussion on: YEW Tutorial: 04 ...and services for all!

Collapse
direstrepo24 profile image
direstrepo24

Hi, i have this error : no method named restore found for enum Result<StorageService, &str> in the current scope
method not found in Result<StorageService, &str>
in line: let Json(database) = storage.restore(KEY); i used 0.18 version of Yew.

Collapse
realrork profile image
realrork

In Yew 0.18 restore method is static with 2 arguments, so code should be now:

fn create(_: Self::Properties, link: ComponentLink<Self>) -> Self {
        let storage = StorageService::new(Area::Local).expect("Error");
        let Json(database) = StorageService::restore(&storage, KEY);
        let database = database.unwrap_or_else(|_| Database::new());
        App {
            link,
            storage,
            database,
            temp_task: Task::new(),
        }
    }
Enter fullscreen mode Exit fullscreen mode