Skip to content
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

how to set default view property's order? #8181

Closed
fov42550564 opened this issue Jun 17, 2016 · 4 comments
Closed

how to set default view property's order? #8181

fov42550564 opened this issue Jun 17, 2016 · 4 comments
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@fov42550564
Copy link

fov42550564 commented Jun 17, 2016

when I create a custom view, it has several properties, how can I make sure these properties' order.

RCT_CUSTOM_VIEW_PROPERTY(props1, NSInteger, MyView) {
   doSomeThing1();
}
RCT_CUSTOM_VIEW_PROPERTY(props2, NSInteger, MyView) {
   doSomeThing2();
}

doSomeThing2 depend on doSomeThing1, so when I set default property I want doSomeThing1 exec before doSomeThing2, as follows:

<MyView props1={1} props2={2} />

Is there has some ways to solve it?

@charpeni
Copy link
Contributor

@facebook-github-bot stack-overflow

@ghost
Copy link

ghost commented Jun 17, 2016

Hey @fov42550564 and thanks for posting this! @charpeni tells me this issue looks like a question that would be best asked on StackOverflow. StackOverflow is amazing for Q&A: it has a reputation system, voting, the ability to mark a question as answered. Because of the reputation system it is likely the community will see and answer your question there. This also helps us use the GitHub bug tracker for bugs only. Will close this as this is really a question that should be asked on SO.

@ghost ghost added the For Stack Overflow label Jun 17, 2016
@ghost ghost closed this as completed Jun 17, 2016
@ghost ghost added the Ran Commands One of our bots successfully processed a command. label Jun 17, 2016
@aleclarson
Copy link
Contributor

aleclarson commented Sep 28, 2016

I'm also facing this issue. Since the props on iOS side are stored in an NSDictionary, the keys are unordered. This means props have no guaranteed order in which they're updated.

Honestly, this behavior seems weird to me.
I assumed the props would be updated based on their order in the JS object.
At the very least, this should be documented better.

@ide Do you know a way around this?

@aleclarson
Copy link
Contributor

Looks like the best solution is to implement didSetProps in your view implementation.

- (void)didSetProps:(NSArray<NSString *> *)changedProps
{
  // Do something that depends on all props having a value.
}

@facebook facebook locked as resolved and limited conversation to collaborators Jun 17, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 19, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants