Skip to content

Commit

Permalink
feat: update templates to use .hana for app
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed Nov 27, 2023
1 parent 394e480 commit 70de901
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 32 deletions.
2 changes: 1 addition & 1 deletion packages/create-hana-app/templates/javascript/index.html
Expand Up @@ -8,6 +8,6 @@
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/_app.jsx"></script>
<script type="module" src="/.hana/_app.jsx"></script>
</body>
</html>
27 changes: 11 additions & 16 deletions packages/create-hana-app/templates/javascript/src/_app.jsx
@@ -1,11 +1,5 @@
import React from 'react';
import ReactDOM from 'react-dom/client';

import { createRouter } from '@hanabira/router';
import { PersistedState, createStore } from '@hanabira/store';

import routes from '../.hana/routes.json';

import './index.css';

/**
Expand All @@ -20,6 +14,7 @@ createStore({
state: {
count: 0,
},

// reducers are functions that allow you to update your state
// you can call them using useReducer('REDUCER_NAME')
reducers: {
Expand All @@ -37,13 +32,13 @@ createStore({
],
});

ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
{createRouter({
usePageTransition: true,
mode: 'history',
root: import.meta.url,
routes,
})}
</React.StrictMode>
);
const Application = ({ children }) => {
/**
* This is the root of your application. You can add any
* global components here. You can also add a global layout
* here if you want to wrap all of your pages in a layout.
*/
return <>{children}</>;
};

export default Application;
2 changes: 1 addition & 1 deletion packages/create-hana-app/templates/typescript/index.html
Expand Up @@ -8,6 +8,6 @@
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/_app.tsx"></script>
<script type="module" src="/.hana/_app.tsx"></script>
</body>
</html>
25 changes: 11 additions & 14 deletions packages/create-hana-app/templates/typescript/src/_app.tsx
@@ -1,11 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom/client';

import { createRouter } from '@hanabira/router';
import { PersistedState, createStore } from '@hanabira/store';

import routes from '../.hana/routes.json';

import './index.css';

/**
Expand All @@ -20,6 +15,7 @@ createStore({
state: {
count: 0,
},

// reducers are functions that allow you to update your state
// you can call them using useReducer('REDUCER_NAME')
reducers: {
Expand All @@ -37,12 +33,13 @@ createStore({
],
});

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
{createRouter({
mode: 'history',
root: import.meta.url,
routes,
})}
</React.StrictMode>
);
const Application: React.FC<React.PropsWithChildren> = ({ children }) => {
/**
* This is the root of your application. You can add any
* global components here. You can also add a global layout
* here if you want to wrap all of your pages in a layout.
*/
return <>{children}</>;
};

export default Application;

0 comments on commit 70de901

Please sign in to comment.