-
-
Notifications
You must be signed in to change notification settings - Fork 48
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Dependancies:
"@prefresh/babel-plugin": "^0.4.1"
"@prefresh/webpack": "^3.2.0"
"webpack": "^4.46.0",
"webpack-dev-server": "^3.11.2",
"webpack-hot-middleware": "^2.25.0",
"preact": "^10.5.12"
webpack is set up to use preact/compat
There are following files:
HOC.jsx // This just represents generic HOC. Originally I faced this issue when using useIntl from 'react-intl' and withTheme from 'styled-components' and it can be reproduced using them as well
import React from 'react'
export const applyHOC = (Component) => (props) => <Component {...props} HOCApplied={true} />
List.jsx
import React from 'react'
import Item from './ListItem'
const items = [0, 1, 2, 3]
export const List = () => {
return <div>{items.map(item => <Item key={`item-${item}`} index={item}/>)}</div>
}
ListItem.jsx
import React, { Component } from 'react'
import { applyHOC } from './HOC'
class ListItem extends Component {
render() {
return <div>item {this.props.index}</div>
}
}
const WrappedListItem = applyHOC(ListItem)
export default WrappedListItem
With this set up whenever I try to change ListItem.jsx all items in List are duplicated. (For example I've added word 'updated' to ListItem content)

I've also tried playing with displayName in different ways, but for me it gave no result at all
I've found that if I move wrapping ListItem with HOC to separate file this flow works fine and list items are never duplicated.
So, if I change files to be:
List.jsx
import React from 'react'
import Item from './WrappedListItem'
const items = [0, 1, 2, 3]
export const List = () => {
return <div>{items.map(item => <Item key={`item-${item}`} index={item}/>)}</div>
}
ListItem.jsx
import React, { Component } from 'react'
class ListItem extends Component {
render() {
return <div>item {this.props.index}</div>
}
}
export default ListItem
WrappedListItem.jsx
import { applyHOC } from './HOC'
import Item from './ListItem'
export default applyHOC(Item)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
