-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CreateBlock not being called on Node after update. #60
Comments
you sure the create block is not called - it works for me :/ |
Yeah, I put a print statement in there to check it for sure. I got nothing printed to the console. I reverted the framework to the previous update and it worked as expected. I haven't encountered this issue before the recent update. I will test again in the sample code that I shared with you earlier. |
that's really weird - I'm on HEAD right now and the creation closure seems to be invoked all of the time. |
What is really strange is that it only stopped working in my card component, but it seems to work everywhere else. import Foundation
import UIKit
import Render
struct CardState: State {
var id: String = "Card"
var feature: NodeType = layoutBuilder("")
var titlebar: NodeType = layoutBuilder("")
var cardSize: CGFloat = 1
var layoutAs: String = "layer"
}
class CardComponent: ComponentView<CardState> {
required init() {
super.init()
self.state = CardState()
self.defaultOptions = [.preventViewHierarchyDiff]
}
required init?(coder aDecoder: NSCoder) {
fatalError("Not supported")
}
override func render() -> NodeType {
let card = Node<UIView>(key: state.id,
create: {
let cardView = UIView()
ComponentAnimation.springOn(view: cardView)
return cardView
}) { (view, layout, size) in
let componentSize = self.getSize()
// Add shadow
view.layer.shadowColor = UIColor.black.cgColor
view.layer.shadowOpacity = 0.5
view.layer.shadowOffset = CGSize.init(width: 2, height: 2)
view.layer.shadowRadius = 2
// Perform layout
layout.width = componentSize.width
layout.height = componentSize.width * CardSize.Proportion
configs[self.state.layoutAs]!(layout)
//layout.paddingTop = 6
}
// A content view that clips its contents
let content = Node<UIView> { (view, layout, size) in
let componentSize = self.getSize()
view.isUserInteractionEnabled = true
view.onTap { _ in mainStore.dispatch(ContextActionRemove(sender: view))}
view.layer.cornerRadius = componentSize.width * CardSize.CornerRadiusRatio
view.clipsToBounds = true
layout.percent.width = 100%
layout.percent.height = 100%
layout.alignContent = .center
}
return card.add(children: [ content.add(children: [
state.feature, state.titlebar
])
])
}
private func getSize() -> CGSize {
let componentWidth = (UIScreen.main.bounds.size.width * self.state.cardSize)
return CGSize(width: componentWidth, height: componentWidth * CardSize.Proportion)
}
} |
Well, I tried putting a |
That seems right. You need to have a reuse identifier if you want to use
custom create closure - I will change the api slightly to make this visible.
…On Tue, 11 Jul 2017 at 23:09, Jason Wilhelm ***@***.***> wrote:
Well, I tried putting a reuseIdentifer: "card" before the key: and then
the card started behaving as usual and called create: correctly. If I
remove the reuseIdentifer: again it stops calling the create block.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#60 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAOlAaE5vLUfClswnt68s-DvaYBvNGuxks5sM-R-gaJpZM4OUu1k>
.
|
I was using the
createBlock
to perform some initialization and execute an animation like this:but now this never gets called after I pulled the latest update. Should I be using another block, like
props:
for this?I need to execute this animation just once when my card is created so that it pops on screen. If I put it out in the configuration block it gets called multiple times.
Thanks for your help.
The text was updated successfully, but these errors were encountered: