Skip to content

Commit

Permalink
fix: remove integration store
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Jan 14, 2022
1 parent 4944126 commit a85ec11
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 21 deletions.
4 changes: 1 addition & 3 deletions integrations/base-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
"package.json",
"README.md",
"webpack-build.js",
"webpack-build.d.ts",
"store.js",
"store.d.ts"
"webpack-build.d.ts"
],
"scripts": {
"build": "yarn cross-env NODE_ENV=production rollup -c",
Expand Down
2 changes: 1 addition & 1 deletion integrations/base-integration/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { config } from '../../rollup-config';

export default config({
input: ['./src/index.tsx', './src/webpack-build.ts', './src/store.ts'],
input: ['./src/index.tsx', './src/webpack-build.ts'],
});
6 changes: 0 additions & 6 deletions integrations/base-integration/src/store.ts

This file was deleted.

1 change: 0 additions & 1 deletion integrations/base-integration/store.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion integrations/base-integration/store.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import React, { FC, useMemo } from 'react';
import { Helmet } from 'react-helmet';
import { Layout, LayoutProps } from '@component-controls/base-integration';
import { store } from '@component-controls/base-integration/store';
import { loadStore } from '@component-controls/store';
const bundle = require('component-controls-bundle');

import { GatsbyLink } from '../components/GatsbyLink';

export type GatsbyLayoutProps = Omit<LayoutProps, 'Link' | 'Helmet' | 'store'>;

export const GatsbyLayout: FC<GatsbyLayoutProps> = props => {
const loadedStore = useMemo(() => store(true), []);
const loadedStore = useMemo(() => loadStore(bundle, false), []);
return (
<Layout
Link={GatsbyLink}
Expand Down
15 changes: 8 additions & 7 deletions integrations/react-router-integration/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import React, { FC, ReactElement, useMemo } from 'react';
import { Route } from 'react-router-dom';
import { Helmet } from 'react-helmet';
import { Store } from '@component-controls/core';
import { Layout, LayoutProps } from '@component-controls/base-integration';
import { store } from '@component-controls/base-integration/store';

import { loadStore } from '@component-controls/store';
import { getRoutes } from '@component-controls/routes';
import { ReactRouterLink } from './components/ReactRouterLink';
const bundle = require('component-controls-bundle');

export const store: Store = loadStore(bundle, true);

export const ControlsPage = (
props: Omit<LayoutProps, 'Helmet' | 'Link' | 'store'>,
): FC => {
const loadedStore = useMemo(() => store(false), []);
const DocHome: FC = () => (
<Layout
{...props}
store={loadedStore}
store={store}
Helmet={Helmet as LayoutProps['Helmet']}
Link={ReactRouterLink}
/>
Expand All @@ -23,9 +25,8 @@ export const ControlsPage = (
};

export const useRoutes = (): ReactElement[] => {
const loadedStore = useMemo(() => store(false), []);
const routes = useMemo(() => {
const paths = getRoutes(loadedStore);
const paths = getRoutes(store);
const routes = paths.map(props => (
<Route
key={props.path}
Expand All @@ -35,6 +36,6 @@ export const useRoutes = (): ReactElement[] => {
/>
));
return routes;
}, [loadedStore]);
}, []);
return routes;
};

0 comments on commit a85ec11

Please sign in to comment.