首次安装React,文件更改时网页不会自动重新加载

时间:2019-12-22 19:01:54

标签: reactjs create-react-app

我是第一次安装create-react-app,该页面没有自动刷新。我不知道为什么它起作用,并且我没有任何代码可以显示给您,因为我只是使用react模板。谁能帮我吗?

1 个答案:

答案 0 :(得分:0)

如果没有安装webpack-dev-server,请确保将其安装在新项目中:

dbProducts.addChildEventListener(new ChildEventListener() {
    @Override
    public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {

//      Toast.makeText(ShowNotifActivity.this, "Child Added ", Toast.LENGTH_SHORT).show();

        Intent intent = new Intent(ShowNotifActivity.this, MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_ONE_SHOT);
        String channelId = "MyNotifications";
        NotificationCompat.Builder builder = new NotificationCompat.Builder(getApplicationContext(), channelId)
                .setSmallIcon(R.drawable.notification)
                // .setLargeIcon(R.drawable.ic_notifications_active_black_24dp)

                .setContentTitle("New Notification")
                .setContentText("Click here to View ");
        ;
        NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            NotificationChannel channel = new NotificationChannel(channelId, "MyNotifications", NotificationManager.IMPORTANCE_DEFAULT);
            manager.createNotificationChannel(channel);
        }
        manager.notify(0, builder.build());

    }

    @Override
    public void onChildChanged(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {

    //    Toast.makeText(ShowNotifActivity.this, "Child Changed", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onChildRemoved(@NonNull DataSnapshot dataSnapshot) {

    }

    @Override
    public void onChildMoved(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {

    }

    @Override
    public void onCancelled(@NonNull DatabaseError databaseError) {

    }
});

如果已安装,请参见控制台,并检查webpack-dev-server上是否没有任何错误或信号监听[ws]

如果您使用的是https模式,则需要在webpack-dev-server中进行一些手动更改