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

fix: use fresh context for state #751

Merged
merged 1 commit into from Jun 15, 2023
Merged

Conversation

YoussefRaafatNasry
Copy link
Member

@YoussefRaafatNasry YoussefRaafatNasry commented Jun 14, 2023

The following pattern was used in a lot of Widgets, which caused the UI to not reflect the actual WidgetbookState, because the SomeWidget will now have outdated values of state on some rebuilds.

// Before
@override
Widget build(BuildContext context) {
  final state = WidgetbookState.of(context);
  
  return SomeWidget(
    child: state.someValue,
  );
}

// After
@override
Widget build(BuildContext context) {  
  return SomeWidget(
    builder: (context) => WidgetbookState.of(context).someValue,
  );
}

@docs-page
Copy link

docs-page bot commented Jun 14, 2023

To view this pull requests documentation preview, visit the following URL:

docs.widgetbook.io/~751

Documentation is deployed and generated using docs.page.

@github-actions
Copy link

📦 Build

📑 Review

@YoussefRaafatNasry YoussefRaafatNasry self-assigned this Jun 14, 2023
@github-actions
Copy link

📦 Build

📑 Review

@YoussefRaafatNasry YoussefRaafatNasry merged commit 89ac960 into main Jun 15, 2023
5 checks passed
@YoussefRaafatNasry YoussefRaafatNasry deleted the fix/fresh-context branch June 15, 2023 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant