developit / developit/stockroom
Store properties undefined on "first render"
- Dominant language
- JavaScript
- Stars
- 1.7k
- Forks
- 44
- PR merge metrics
- No merged PRs in 30d
Description
For a reason that I do not know, my store is undefined on "first render".
In that capture of devtools console, I log a property of my store.
It is **first** `undefined` then HMR comes and then the property is `defined`.

```js
import { Component } from 'preact';
import { connect } from 'unistore/preact';
@connect(['toast'])
class Toast extends Component {
render ({toast}, {}) {
console.log(toast);
return (
{/*toast.messages.map((message, index) => (
{message}
))*/}
)
}
}
export default Toast;
```
```js
// store/worker.js
import createStore from 'stockroom/worker';
import idbKeyVal from 'idb-keyval';
import Constants from '../constants';
const store = createStore({
user: {
userId: '',
email: '',
avatar: ''
},
toast: {
messages: [],
show: false
}
});
// globally available actions
store.registerActions(store => ({
toasting ({toast}, messages) {
return {
toast: {
messages,
show: true
}
};
}
}));
```
```js
// index.js
import createStore from 'stockroom';
import storeWorker from 'workerize-loader!./store/worker';
import { Provider, connect } from 'unistore/preact';
import devtools from 'unistore/devtools';
const production = process.env.NODE_ENV === 'production';
const store = production ? createStore(storeWorker()) : devtools(createStore(storeWorker()));
import './style/index.scss';
import App from './components/app';
export default () => (
);
```
I don't have that problem when I only use unistore without stockroom.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.