question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android] Copy button in the redbox should also support Windows and Linux platforms

See original GitHub issue

This is not a bug report but Help Wanted!

I have added a new feature of adding copy button in the redbox for RN Android, which copies the error message and stack trace to the host (your laptop’s) clipboard. Please see Add Copy and Dismiss Button in RN Android Red Box and have a try on it!

However it’s only supported on Mac OS for now. The reason is just that I don’t have available Windows or Linux computers to test this feature on. So I appreciate anyone’s help to add this feature on these two platforms.

Actually I already have the code for you, which I think should work. Please see https://github.com/facebook/react-native/blob/master/local-cli/server/util/copyToClipBoard.js

/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */
'use strict';

var child_process = require('child_process');
// Changes begin.
var iconv = require('iconv-lite');
// Changes end.
var spawn = child_process.spawn;

/**
 * Copy the content to host system clipboard.
 * This is only supported on Mac for now.
 */
function copyToClipBoard(content) {
  switch (process.platform) {
  case 'darwin':
    var child = spawn('pbcopy', []);
    child.stdin.end(new Buffer(content, 'utf8'));
    return true;
  // Changes begin.
  case 'linux':
    var child = spawn('xclip', ['-selection', 'clipboard']);
    child.stdin.end(new Buffer(content, 'utf8'));
    return true;
  case 'win32':
    var child = spawn('clip', []);
    child.stdin.end(iconv.encode(content, 'utf16le'));
    return true;
  // Changes end.
  default:
    return false;
  }
}

module.exports = copyToClipBoard;

The code between // Changes begin. and // Changes end. are the only things to be added by you. (Don’t forget to add the dependency for iconv at the beginning.) Hope this will work on Windows and Linux!

If anyone needs more information on this, feel free to contact me.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
lebronJcommented, Nov 8, 2016

@jrodiger Thanks for your interest! This feature is extremely easy for you to test and enable on Windows. Here are some steps as follows: (1) Make a mistake and trigger a red box, where I believe there will be a copy button on the bottom. (2) Pressing the copy button should behave the same as on Mac OS (copy the red box information onto your host PC clipboard), however it’s not enabled on Windows as I described in this issue. What you could help is to follow my guidance in this issue above and try to enable this feature at https://github.com/facebook/react-native/blob/master/local-cli/server/util/copyToClipBoard.js

Hope this will help and this feature will be enabled with your effort and help!

0reactions
hramoscommented, Jul 21, 2017

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we’re automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enterprise Browser Setup - Zebra Technologies TechDocs
Copy the Enterprise Browser runtime for Android to internal storage, which is opened by default. Storage buttons (red arrow) will be shown only...
Read more >
React Native Tutorial for Beginners - YouTube
React Native Tutorial for Beginners - Learn to build an amazing React Native app for iOS & Android. Get the full...
Read more >
Run Button is Disabled in Android Studio - Stack Overflow
Click Run on the menu and then Edit Configurations... then click on Android Application on the left and click the + button. Choose...
Read more >
Is the Redbox TV app safe for Android? - Quora
RedBox TV APK is an entirely safe and secure APK. But you have to download it from a legit platform like apktwin.com Using...
Read more >
Create UI tests with Espresso Test Recorder
The following examples demonstrate where a test would save for the Notes testing app: If you are using the Android view within the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found