Skip to content

Commit 3efdd8a

Browse files
renatoribpedronauck
authored andcommitted
fix(inline): don't recreate adopt instance in every render (#12)
1 parent c293003 commit 3efdd8a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/index.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,14 @@ export type AdoptProps<RP, P> = P & {
8787
children: ChildrenFn<RP>
8888
}
8989

90-
export const Adopt: React.SFC<AdoptProps<any, any>> = props => {
91-
const Composed = adopt(props.mapper)
92-
const composedProps = omit(['children', 'mapper'], props)
90+
export class Adopt extends React.Component<AdoptProps<any, any>> {
91+
constructor(props) {
92+
super(props)
93+
this.Composed = adopt(props.mapper)
94+
}
9395

94-
return <Composed {...composedProps}>{props.children}</Composed>
96+
render() {
97+
const { mapper, ...props } = this.props
98+
return <this.Composed {...props} />
99+
}
95100
}

0 commit comments

Comments
 (0)