| 29 | const unmounted = createEvent<any>() |
| 30 | |
| 31 | function RenderComponent(props: Props) { |
| 32 | const propsRef = React.useRef(props) |
| 33 | const state = useStore(store) |
| 34 | useIsomorphicLayoutEffect(() => { |
| 35 | mounted({props: propsRef.current, state: store.getState()}) |
| 36 | return () => { |
| 37 | unmounted({props: propsRef.current, state: store.getState()}) |
| 38 | } |
| 39 | }, []) |
| 40 | const result = renderProp(props, state) |
| 41 | propsRef.current = props |
| 42 | return result |
| 43 | } |
| 44 | RenderComponent.mounted = mounted |
| 45 | RenderComponent.unmounted = unmounted |
| 46 | return withDisplayName(`${storeName}.View`, RenderComponent) |