Fixed issue for dynamic props update#28
Fixed issue for dynamic props update#28lttb merged 5 commits intocssinjs:masterfrom wellguimaraes:master
Conversation
lttb
left a comment
There was a problem hiding this comment.
@wellguimaraes, thank you for this fix, that's great!
| if (rule.name) | ||
| this.sheet.update(rule.name, props) | ||
| else | ||
| this.sheet.update(props) |
There was a problem hiding this comment.
The problem here is that in this case we update the whole StyleSheet, and it will reduce performance significantly. That's why we update by the name, otherwise we can replace all that code with just this.sheet.update :).
Another problem with such update is that we will rerender rules for other instances, that were not really updated.
But this solution should work:
if (rule.name) this.sheet.update(rule.name, props)
if (rule.rules) rule.rules.update(props)Conditional rules has their own RulesContainer in rules, so with .update we should iterate only for needed rules.
|
There are also some issues with codestyle. Anyway I'll setup linting by CI too |
|
|
||
| const wrapper = mount(<Button spaced />) | ||
|
|
||
| expect(styled.mountSheet().toString()).toMatchSnapshot() |
There was a problem hiding this comment.
we should use assertSheet here. but I checked that getCss returns empty media query rule for function values like:
.button-1-id{padding:10px;}@mediascreen{.button-1-id{}}
for static values it's ok.
need to understand why dynamic properties didn't render with values for conditional rules
| wrapper.unmount() | ||
| }) | ||
|
|
||
| it('should update all dynamic props', () => { |
There was a problem hiding this comment.
I think it would be better to name this test like 'should update dynamic props for conditional rules'
|
@wellguimaraes please rebase your branch by origin, I've fixed Travis config and eslint checks |
|
|
||
| expect(styled.mountSheet().toString()).toMatchSnapshot() | ||
| wrapper.setProps({spaced: false}) | ||
| expect(styled.mountSheet().toString()).toMatchSnapshot() |
|
@wellguimaraes It looks like it still does not work for me (with whole sheet update too) |
need to understand issues with rendering of dynamic conditional rules
|
There is an issue w/ jss: cssinjs/jss#511 |
|
@wellguimaraes it looks like we have fix it, is it okay now? it works here: https://codesandbox.io/s/M8o5p00rP |
|
awesome! |
Uh oh!
There was an error while loading. Please reload this page.