Skip to content

Commit

Permalink
fix(renderComponent): 修正 key 赋值时机
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Jan 4, 2021
1 parent 4f7ecff commit 516456e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/react/renderComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ export function renderComponent<TComponent extends React.ComponentType<any>>(
let destroy!: () => void

const prepareProps = (props: Partial<React.ComponentProps<TComponent>>) => {
props = {
key: Date.now(),
...props,
}
props = { ...props }
if (injectCallbacks) {
for (const key of Object.keys(injectCallbacks)) {
const originalCallback = props[key]
Expand Down Expand Up @@ -115,9 +112,12 @@ export function renderComponent<TComponent extends React.ComponentType<any>>(
}
}

render(initialProps)
let incrementalProps: React.ComponentProps<TComponent> = {
key: Date.now(),
...initialProps,
}

let incrementalProps: React.ComponentProps<TComponent> = { ...initialProps }
render(incrementalProps)

return {
incrementalRerender(props: Partial<React.ComponentProps<TComponent>>) {
Expand Down

0 comments on commit 516456e

Please sign in to comment.