Skip to content

Commit 70c2ce6

Browse files
author
Yulia Klein
authored
Merge pull request #9 from qmatteoq/master
Updated to latest React Native for Windows snapshot
2 parents ded0d34 + 0193148 commit 70c2ce6

File tree

18 files changed

+1001
-720
lines changed

18 files changed

+1001
-720
lines changed

samples/TodosFeed/TodosFeed/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
"dependencies": {
1111
"react": "16.8.6",
1212
"react-native": "^0.60.0",
13-
"react-native-windows": "0.60.0-vnext.23",
14-
"rnpm-plugin-windows": "^0.3.5"
13+
"react-native-windows": "0.60.0-vnext.71",
14+
"rnpm-plugin-windows": "^0.3.8"
1515
},
1616
"devDependencies": {
17-
"@babel/core": "^7.6.3",
18-
"@babel/runtime": "^7.6.3",
17+
"@babel/core": "^7.7.2",
18+
"@babel/runtime": "^7.7.2",
1919
"@react-native-community/eslint-config": "^0.0.5",
2020
"babel-jest": "^24.9.0",
21-
"eslint": "^6.5.1",
21+
"eslint": "^6.6.0",
2222
"jest": "^24.9.0",
23-
"metro-react-native-babel-preset": "^0.56.0",
23+
"metro-react-native-babel-preset": "^0.57.0",
2424
"react-test-renderer": "16.8.6"
2525
},
2626
"jest": {

samples/TodosFeed/TodosFeed/windows/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,7 @@ packages/
8686
*.DotSettings
8787
.vs/
8888
*project.lock.json
89+
90+
#Files generated by the VS build
91+
**/Generated Files/**
92+

samples/TodosFeed/TodosFeed/windows/TodosFeed.Component/TodosFeedControl.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public TodosFeedControl()
1515

1616
public void LoadReact()
1717
{
18-
InstanceSettings settings;
18+
InstanceSettings settings = new IntanceSettings();
1919

2020
settings.UseLiveReload = true;
2121
settings.UseWebDebugger = true;

samples/TodosFeed/TodosFeed/windows/TodosFeed.sln

Lines changed: 301 additions & 35 deletions
Large diffs are not rendered by default.
Lines changed: 28 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,46 @@
11
#include "pch.h"
22

33
#include "App.h"
4-
#include "MainPage.h"
4+
#include "ReactPackageProvider.h"
55

6-
using namespace winrt;
7-
using namespace Windows::ApplicationModel;
8-
using namespace Windows::ApplicationModel::Activation;
9-
using namespace Windows::Foundation;
10-
using namespace Windows::UI::Xaml;
11-
using namespace Windows::UI::Xaml::Controls;
12-
using namespace Windows::UI::Xaml::Navigation;
136

147

15-
using namespace TodosFeed;
16-
using namespace TodosFeed::implementation;
8+
using namespace winrt::TodosFeed;
9+
using namespace winrt::TodosFeed::implementation;
1710

1811
/// <summary>
19-
/// Initializes the singleton application object. This is the first line of authored code
20-
/// executed, and as such is the logical equivalent of main() or WinMain().
12+
/// Initializes the singleton application object. This is the first line of
13+
/// authored code executed, and as such is the logical equivalent of main() or
14+
/// WinMain().
2115
/// </summary>
22-
App::App()
16+
App::App() noexcept
2317
{
24-
InitializeComponent();
25-
Suspending({ this, &App::OnSuspending });
26-
27-
#if defined _DEBUG && !defined DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
28-
UnhandledException([this](IInspectable const&, UnhandledExceptionEventArgs const& e)
29-
{
30-
if (IsDebuggerPresent())
31-
{
32-
auto errorMessage = e.Message();
33-
__debugbreak();
34-
}
35-
});
18+
MainComponentName(L"TodosFeed");
19+
20+
#if BUNDLE
21+
JavaScriptBundleFile(L"index.windows");
22+
InstanceSettings().UseWebDebugger(false);
23+
InstanceSettings().UseLiveReload(false);
24+
#else
25+
JavaScriptMainModuleName(L"index");
26+
InstanceSettings().UseWebDebugger(true);
27+
InstanceSettings().UseLiveReload(true);
3628
#endif
37-
}
38-
39-
/// <summary>
40-
/// Invoked when the application is launched normally by the end user. Other entry points
41-
/// will be used such as when the application is launched to open a specific file.
42-
/// </summary>
43-
/// <param name="e">Details about the launch request and process.</param>
44-
void App::OnLaunched(LaunchActivatedEventArgs const& e)
45-
{
46-
Frame rootFrame{ nullptr };
47-
auto content = Window::Current().Content();
48-
if (content)
49-
{
50-
rootFrame = content.try_as<Frame>();
51-
}
52-
53-
// Do not repeat app initialization when the Window already has content,
54-
// just ensure that the window is active
55-
if (rootFrame == nullptr)
56-
{
57-
// Create a Frame to act as the navigation context and associate it with
58-
// a SuspensionManager key
59-
rootFrame = Frame();
6029

61-
rootFrame.NavigationFailed({ this, &App::OnNavigationFailed });
30+
#if _DEBUG
31+
InstanceSettings().EnableDeveloperMenu(true);
32+
#else
33+
InstanceSettings().EnableDeveloperMenu(false);
34+
#endif
6235

63-
if (e.PreviousExecutionState() == ApplicationExecutionState::Terminated)
64-
{
65-
// Restore the saved session state only when appropriate, scheduling the
66-
// final launch steps after the restore is complete
67-
}
36+
PackageProviders().Append(make<ReactPackageProvider>()); // Includes all modules in this project
6837

69-
if (e.PrelaunchActivated() == false)
70-
{
71-
if (rootFrame.Content() == nullptr)
72-
{
73-
// When the navigation stack isn't restored navigate to the first page,
74-
// configuring the new page by passing required information as a navigation
75-
// parameter
76-
rootFrame.Navigate(xaml_typename<TodosFeed::MainPage>(), box_value(e.Arguments()));
77-
}
78-
// Place the frame in the current Window
79-
Window::Current().Content(rootFrame);
80-
// Ensure the current window is active
81-
Window::Current().Activate();
82-
}
83-
}
84-
else
85-
{
86-
if (e.PrelaunchActivated() == false)
87-
{
88-
if (rootFrame.Content() == nullptr)
89-
{
90-
// When the navigation stack isn't restored navigate to the first page,
91-
// configuring the new page by passing required information as a navigation
92-
// parameter
93-
rootFrame.Navigate(xaml_typename<TodosFeed::MainPage>(), box_value(e.Arguments()));
94-
}
95-
// Ensure the current window is active
96-
Window::Current().Activate();
97-
}
98-
}
99-
}
100-
101-
/// <summary>
102-
/// Invoked when application execution is being suspended. Application state is saved
103-
/// without knowing whether the application will be terminated or resumed with the contents
104-
/// of memory still intact.
105-
/// </summary>
106-
/// <param name="sender">The source of the suspend request.</param>
107-
/// <param name="e">Details about the suspend request.</param>
108-
void App::OnSuspending([[maybe_unused]] IInspectable const& sender, [[maybe_unused]] SuspendingEventArgs const& e)
109-
{
110-
// Save application state and stop any background activity
111-
}
38+
InitializeComponent();
11239

113-
/// <summary>
114-
/// Invoked when Navigation to a certain page fails
115-
/// </summary>
116-
/// <param name="sender">The Frame which failed navigation</param>
117-
/// <param name="e">Details about the navigation failure</param>
118-
void App::OnNavigationFailed(IInspectable const&, NavigationFailedEventArgs const& e)
119-
{
120-
throw hresult_error(E_FAIL, hstring(L"Failed to load Page ") + e.SourcePageType().Name);
40+
// This works around a cpp/winrt bug with composable/aggregable types tracked
41+
// by 22116519
42+
AddRef();
43+
m_inner.as<::IUnknown>()->Release();
12144
}
12245

12346

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#pragma once
2+
23
#include "App.xaml.g.h"
34

45

@@ -7,12 +8,8 @@ namespace winrt::TodosFeed::implementation
78
{
89
struct App : AppT<App>
910
{
10-
App();
11-
12-
void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs const&);
13-
void OnSuspending(IInspectable const&, Windows::ApplicationModel::SuspendingEventArgs const&);
14-
void OnNavigationFailed(IInspectable const&, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs const&);
11+
App() noexcept;
1512
};
16-
}
13+
} // namespace winrt::TodosFeed::implementation
1714

1815

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
<Application
1+
<react:ReactApplication
22
x:Class="TodosFeed.App"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5-
xmlns:local="using:TodosFeed">
5+
xmlns:local="using:TodosFeed"
6+
xmlns:react="using:Microsoft.ReactNative">
67

7-
</Application>
8+
</react:ReactApplication>

samples/TodosFeed/TodosFeed/windows/TodosFeed/MainPage.cpp

Lines changed: 0 additions & 46 deletions
This file was deleted.

samples/TodosFeed/TodosFeed/windows/TodosFeed/MainPage.h

Lines changed: 0 additions & 25 deletions
This file was deleted.

samples/TodosFeed/TodosFeed/windows/TodosFeed/MainPage.idl

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)