aksonov / aksonov/react-native-router-flux

Using Router With Styled Components OR HOCs causing unnecessary re-renders

未关闭
#3,372 0 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
JavaScript
星标
8.9k
派生
2.1k
PR 合并指标
30 天内没有已合并 PR

描述

### Version
Tell us which versions you are using:

- react-native-router-flux v4.0.6
- react v16.3.1
- react-native v0.55.4

### Expected behaviour
Provide Styles to my Router (navigationBarStyles, titleStyle etc... using Styled Components). I am using styled components v 4.1.2 to style my Router like so

`
const StyledRouter=styled(Router).attrs(props=>({
navigationBarStyle:{backgroundColor:props.theme.bgcolor},
...etc
})) `\`Tagged Literal stuff...\`

**My Main App Component**
`


{routes}

`

### Actual behaviour
All My Scenes Are being Unmounted and mounted continuously until I get an error and the app becomes completely non responsive and shuts off ( but the styling works perfectly).

Is it because styled is essentially an HOC, and is this causing re-renders? However, I have no problems using styled components in my other parts of the App.
**UPDATE**
I feel it is how the Router Component plays with HOCs, I tried it with withTheme HOC and I faced the same issue, for now the workaround is to use the global instance of my theme object and directly pass as props.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。