Code Monkey home page Code Monkey logo

Comments (6)

diegohaz avatar diegohaz commented on June 12, 2024 1

Ah, I thought you were talking about a different thing.

Anyway, it's super easy to get the same API:

const [CounterProvider, useCounterContext] = constate(useCounter);
useCounterContext.Provider = CounterProvider;
export { useCounterContext };

from constate.

diegohaz avatar diegohaz commented on June 12, 2024

It's not possible. You would have to create a separate file and export both:

import constate from "constate";
import useCounter from "./counterContext";

export const [CounterProvider, useCounterContext] = constate(useCounter);

from constate.

tolgaduzenli avatar tolgaduzenli commented on June 12, 2024

@diegohaz Thanks for the quick response.
I am using previous version (not 2.0.0), TBH, it was easier than now. I dont why you converted this way. Most probably you have reason(s) to have like this.
Maybe I misunderstood and couldnt figure out how can I import just one ContextProvider above everything, and access context from children components. Exactly like we were using with previous version.

from constate.

diegohaz avatar diegohaz commented on June 12, 2024

I don't remember this being possible in v1. How were you doing it?

from constate.

tolgaduzenli avatar tolgaduzenli commented on June 12, 2024

yes here it is; codesandbox
please check version of constate

from constate.

tolgaduzenli avatar tolgaduzenli commented on June 12, 2024

Thanks @diegohaz I knew I misunderstood the concept. Updated same codesandbox with new version and your suggestion. If someone needs, just check same codesandbox from previous psts.

from constate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.