Skip to content

Commit

Permalink
feat(react): provide hooks for config & server-data contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
Emanuel Kluge authored and herschel666 committed Oct 28, 2019
1 parent e5279b8 commit 6bfaf55
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/react/config/use-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const React = require('react');
const ConfigContext = require('./context');

function useConfig() {
return React.useContext(ConfigContext);
}

module.exports = useConfig;
4 changes: 4 additions & 0 deletions packages/react/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ const {
} = require('@untool/react/lib/runtime');
const ServerDataContext = require('./server-data/context');
const withServerData = require('./server-data/with-server-data');
const useServerData = require('./server-data/use-server-data');

const ConfigContext = require('./config/context');
const withConfig = require('./config/with-config');
const useConfig = require('./config/use-config');

module.exports = {
Header,
Expand All @@ -19,6 +21,8 @@ module.exports = {
render,
ServerDataContext,
withServerData,
useServerData,
ConfigContext,
withConfig,
useConfig,
};
8 changes: 8 additions & 0 deletions packages/react/server-data/use-server-data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const React = require('react');
const ServerDataContext = require('./context');

function useServerData() {
return React.useContext(ServerDataContext);
}

module.exports = useServerData;

0 comments on commit 6bfaf55

Please sign in to comment.