diegohaz / constate

React Context + State
https://codesandbox.io/s/github/diegohaz/constate/tree/master/examples/counter
MIT License
3.93k stars 90 forks source link

Allow user to control console #104

Open MattShrider opened 4 years ago

MattShrider commented 4 years ago

I currently intentionally have some providers as optional, so I often get console warnings from constate about the provider not being provided.

    if (isDev && value === NO_PROVIDER) {
      // eslint-disable-next-line no-console
      console.warn("[constate] Component not wrapped within a Provider.");
    }

I would like to hide them for my use-case. I'd recommend the feature be "fixed" by allowing the user to add their own console object, then it would be up to the user to filter this specific message.

import constate, { useConsole } from 'constate';
import log from 'loglevel';

const constateLogger= log.getLogger('constate');
constateLogger.setLevel(log.levels.ERROR);
useConsole(constateLogger)

const [Provider, hook] = constate(.....);
aspirisen commented 2 years ago

Hi, any updates on optional providers? I think it is often case when you have no providers.