Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat/harmony' into feat/harmony-…
Browse files Browse the repository at this point in the history
…style
  • Loading branch information
ZakaryCode committed Jun 24, 2024
2 parents 42256c6 + 1de88e5 commit f43d441
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/taro-framework-react/src/vite.harmony.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function aliasPlugin (ctx: IPluginContext, framework: Frameworks): PluginOption
config (config) {
const alias: ({ find: string | RegExp, replacement: string })[] = [
{ find: /react-dom$/, replacement: '@tarojs/react' },
{ find: /react-dom\/client$/, replacement: '@tarojs/react' },
]

const mainFields = ['unpkg', ...defaultMainFields]
Expand Down
3 changes: 2 additions & 1 deletion packages/taro-framework-react/src/vite.mini.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ function aliasPlugin (ctx: IPluginContext, framework: Frameworks): PluginOption
name: 'taro-react:alias',
config (config) {
const alias: ({ find: string | RegExp, replacement: string })[] = [
{ find: /react-dom$/, replacement: '@tarojs/react' }
{ find: /react-dom$/, replacement: '@tarojs/react' },
{ find: /react-dom\/client$/, replacement: '@tarojs/react' },
]

const mainFields = ['unpkg', ...defaultMainFields]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,9 @@ function initNativeComponentEntry (params: InitNativeComponentEntryParams) {
app?.appendChild(nativeApp)
app = nativeApp
}
// eslint-disable-next-line react/no-deprecated
ReactDOM.render(h(Entry, {}), app)
// const root = ReactDOM.createRoot(app)
// root.render?.(h(Entry))

const root = ReactDOM.createRoot(app)
root.render?.(h(Entry))
}


Expand Down
7 changes: 7 additions & 0 deletions packages/taro-react/src/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,18 @@ export function updateProps (dom: TaroElement, oldProps: Props, newProps: Props)

export function updatePropsByPayload (dom: TaroElement, oldProps: Props, updatePayload: any[]) {
const handlers: (() => void)[] = []
let fixedHandler: (() => void) | null = null
for (let i = 0; i < updatePayload.length; i += 2) {
// key, value 成对出现
const key = updatePayload[i]
const newProp = updatePayload[i + 1]
const oldProp = oldProps[key]
if (isHarmony) {
if (key === '__fixed') {
// hack: __fixed最先识别
fixedHandler = () => setProperty(dom, key, newProp, oldProp)
continue
}
// 鸿蒙样式前置插入,防止覆盖style
if (key === '__hmStyle') {
handlers.splice(0, 0, () => setHarmonyStyle(dom, newProp, oldProp))
Expand All @@ -70,6 +76,7 @@ export function updatePropsByPayload (dom: TaroElement, oldProps: Props, updateP
}
}
if (isHarmony) {
fixedHandler && fixedHandler()
for (let i = 0; i < handlers.length; i++) {
handlers[i]()
}
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-vite-runner/src/harmony/template/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ callFn(this.page?.onReady, this, params)`
const isCustomNavigationBar = this.appConfig.window?.navigationStyle === 'custom'
let pageStr = ''
if (this.buildConfig.isBuildNativeComp) {
return `if (true) {
return `if (this.node) {
TaroView({ node: this.node as TaroViewElement, createLazyChildren: createLazyChildren })
if (${isTabPage ? 'this.layerNode[index]' : 'this.layerNode'}) {
Stack() {
Expand Down

0 comments on commit f43d441

Please sign in to comment.