Mantra-core is depreciated?

Hello guys, i have an project in meteor 1.5 but like do updade for 1.9 and react 16, but i use this lib mantra-core and this lib doesn’t work in this version of meteor, someone knows how i replace this lib for another?
this is an example of my use this lib
import { useDeps, composeAll, composeWithTracker, compose } from ‘mantra-core’;

export default composeAll(

composeWithTracker(composer),

useDeps(depsMapper)

)(Dashboard);

Hi @fabiolo,
Back in the days I have used Mantra and had to migrate away from it.
For mantra-core it is actually multiple packages in one. If possible you don’t want to use compose and composeAll at all in your new version and migrate to hooks. If you can’t, use the recompose npm package which superseded it and replace composeAll with compose (if the order of HOC matters then remember that the order is switched then what you are used to). I think you will find useDeps in recompose as well.
For composeWithTracker you will replace that either with withTracker (HOC) or useTracker (hook) from React Meteor Data package.

Since you are at it, I would encourage you to go straight to the newest Meteor 1.10.1 (not much different from the 1.9 versions).

Let me know if you have any questions.

Hi @storyteller i`m trying to do this changes, after that i will answer you, if i can do this.
thanks for help.

1 Like

Hi @storyteller , do you have any suggest for me, i need replace this code.
app = createApp(context).

this prop createApp comes from mantra.
import { createApp } from ‘mantra-core’;

i try change this with React.createContext(context).
but i need load modules.
this is my code.

import React from ‘react’;

import initContext from ‘./configs/context’;

// modules

import coreModule from ‘./modules/core’;

import appModule from ‘./modules/app’;

import generalModule from ‘./modules/general’;

import hardwareModule from ‘./modules/hardware’;

import dashboardModule from ‘./modules/dashboard’;

import compressorModule from ‘./modules/compressor’;

import chartModule from ‘./modules/chart’;

import sensorModule from ‘./modules/sensor’;

// init context

const context = initContext();

// create app
this line, i`m trying to change
““const app = React.createContext(context);””

const app = createApp(context);

app.loadModule(coreModule);

app.loadModule(appModule);

app.loadModule(generalModule);

app.loadModule(hardwareModule);

app.loadModule(dashboardModule);

app.loadModule(compressorModule);

app.loadModule(chartModule);

app.loadModule(sensorModule);

app.init();

I don’t recall exactly what approach I took, but by looking on my code today I think I rewrote this entire part here with react-router. Define the base route for each module that is linked to the router in the module and then I load context with hooks for each component as needed. So something like this (pseudo code):

<Router>
  <Route to='/workshop' component={WorkshopRouter} />
</Router>

If I remember correctly the main thing that I was doing here with this part of Mantra was because of routes. Let me know if I’m totally off the mark and I’ll look more into it.

1 Like

Hi @storyteller sorry for asking again, but can you show me how do you load context whit hooks?

Depends on what you mean by context. Is that data from DB or some other variables?

1 Like

my context it`s the data from DB.

Check out this readme:
https://github.com/meteor/react-packages/tree/devel/packages/react-meteor-data#usetrackerreactivefn-deps-hook

A quick example at the beginning of a component would look like this:

const loading = useTracker(() => !Meteor.subscribe('myBooks').ready(), [userId]);
const myBooks = useTracker(() => MyBooks.find().fetch(), [loading]);
if (loading) return <Loading />;