You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 22, 2026. It is now read-only.
Implement a React-like context API for dsl-lite to allow component authors to share values without explicit prop passing. This should include both createContext and useContext functions.
Tasks
Implement a context stack mechanism to manage context values
Create createContext function to create context objects
Implement useContext hook to consume context values
Ensure proper typing for context values
Add provider functionality to inject context values
Create tests for context creation and consumption
Technical Details
// Context implementationconstcontextStack: Array<{context: any,value: any}>=[];// createContext functionexportfunctioncreateContext<T>(defaultValue: T){constcontext={$$typeof: Symbol.for('jsx.context'),_defaultValue: defaultValue,Provider: nullasany};context.Provider={$$typeof: Symbol.for('jsx.provider'),_context: context};returncontext;}// useContext hookexportfunctionuseContext<T>(context: any): T{hookIndex++;// Increment hook index to maintain order// Search for context in stackfor(leti=contextStack.length-1;i>=0;i--){if(contextStack[i].context===context){returncontextStack[i].value;}}// Return default if not foundreturncontext._defaultValue;}// Push context to stackexportfunctionpushContext(context: any,value: any){contextStack.push({ context, value });}// Pop context from stackexportfunctionpopContext(){contextStack.pop();}
Description
Implement a React-like context API for
dsl-liteto allow component authors to share values without explicit prop passing. This should include bothcreateContextanduseContextfunctions.Tasks
createContextfunction to create context objectsuseContexthook to consume context valuesTechnical Details