diff --git a/playground/src/context/index.js b/playground/src/context/index.js index 8d58a922ffe..ae0650d3d71 100644 --- a/playground/src/context/index.js +++ b/playground/src/context/index.js @@ -1,21 +1,20 @@ const React = require('react'); -let ctx = { +const _context = { title: 'Title from global context', count: 0 }; - -const stateAwareContext = (component) => - new Proxy(ctx, { - set: function (obj, prop, value) { - obj[prop] = value; - component.setState({ context: stateAwareContext(component) }); - return true; - } - }); +const contextWrapper = (component) => ({ + ..._context, + incrementCount: () => { + _context.count++; + component.setState({ context: contextWrapper(component) }) + } +}); const GlobalContext = React.createContext({}); class ContextProvider extends React.Component { - state = {context :stateAwareContext(this)}; + state = { context: contextWrapper(this) } + render() { return ( diff --git a/playground/src/screens/ContextScreen.js b/playground/src/screens/ContextScreen.js index 3eb2e0fd729..c6c26641030 100644 --- a/playground/src/screens/ContextScreen.js +++ b/playground/src/screens/ContextScreen.js @@ -24,7 +24,7 @@ class ContextScreen extends React.Component { {ctx => Provider value: {ctx.title}} - {ctx =>