parent
97d4e8018b
commit
0debfaa034
@ -1,27 +0,0 @@ |
||||
import type { Profile, LocationProfile } from '@remixproject/plugin-utils' |
||||
import { Plugin } from '@remixproject/engine' |
||||
|
||||
|
||||
export function isView<P extends Profile>(profile: Profile): profile is (ViewProfile & P) { |
||||
return !!profile['location'] |
||||
} |
||||
|
||||
export type ViewProfile = Profile & LocationProfile |
||||
|
||||
export abstract class ViewReactPlugin extends Plugin { |
||||
abstract render(): any |
||||
|
||||
constructor(public profile: ViewProfile) { |
||||
super(profile) |
||||
} |
||||
|
||||
async activate() { |
||||
await this.call(this.profile.location, 'addView', this.profile, this.render()) |
||||
super.activate() |
||||
} |
||||
|
||||
deactivate() { |
||||
this.call(this.profile.location, 'removeView', this.profile) |
||||
super.deactivate() |
||||
} |
||||
} |
@ -1,2 +1,3 @@ |
||||
export * from './lib/remix-ui-helper' |
||||
export * from './lib/helper-components' |
||||
export * from './lib/components/PluginViewWrapper' |
@ -1,25 +1,20 @@ |
||||
import React from "react" |
||||
import { useEffect, useState } from "react" |
||||
|
||||
interface IViewPluginUI { |
||||
interface IPluginViewWrapperProps { |
||||
plugin: any |
||||
} |
||||
|
||||
export const ViewPluginUI = (props: IViewPluginUI) => { |
||||
export const PluginViewWrapper = (props: IPluginViewWrapperProps) => { |
||||
|
||||
const [state, setState] = useState<any>(null) |
||||
|
||||
useEffect(() => { |
||||
// console.log(props.plugin)
|
||||
if(props.plugin.setDispatch){ |
||||
props.plugin.setDispatch(setState) |
||||
} |
||||
}, []) |
||||
|
||||
useEffect(() => { |
||||
// console.log(state)
|
||||
}, [state]) |
||||
|
||||
|
||||
return ( |
||||
<>{state?
|
||||
<>{props.plugin.updateComponent(state)}</> |
Loading…
Reference in new issue