Solve – cors problem


app.use(function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
  next();
});

app.get('/', function(req, res, next) {
  // ....
});

app.post('/', function(req, res, next) {
 // ....
});



React createElement – Warning: Unknown prop `childItems` on

The following command creates an element in React.


    const el = React.createElement(
                 < an html tag or react component >, 
                 < attributes or props or {} >, 
                 < children elements or text >
    )

When you pass a non html standard attributes in the second parameter to create html tag like div or p tag then a warning is raised of unknown prop. Simply remove the non standard attribute from the second parameter or pass empty object {}.

Ubuntu 17.10 expo and genymotion errors and solutions

Error:

Switched to a LAN URL because the tunnel appears to be down. Only devices in the same network can access the app. You can restart the project to try reconnecting.

Solution:

Due to some bug you must start xde (expo development environment) before genymotion. Also i needed to run xde from root user login. (not su or sudo ).
UPDATE: The following problem of adb version fixed this problem too.

===================================================================

Error:

Couldn’t start project on Android: could not install *smartsocket* listener: Address already in use
ADB server didn’t ACK
* failed to start daemon *
error: cannot connect to daemon

Solution:

the adb version on your system is different from the adb version on the android sdk platform-tools

1. check sys adb version

# adb version
Android Debug Bridge version 1.0.39

2. check sdk adb version

# cd /root/Android/Sdk/platform-tools
# ./adb version
Android Debug Bridge version 1.0.32

3. copy
# rm /usr/bin/adb
# sudo cp /root/Android/Sdk/platform-tools/adb /usr/bin/adb

=============================================================

Error:
Error: EACCES: permission denied, open ‘/tmp/haste-map-react-native-packager-1-8963e41d25a58e25717f5939e5144fc2

Solution: sudo rm /tmp/haste-map-react-native-packager-1-8963e41d25a58e25717f5939e5144fc2

========================================================
Error:
The development server returned response error code: 500

Solution:
For me this error was resolved running yarn in the project folder. The cause may have been due to the fact that I’d switched branches and some of the packages were not installed.

The state object

The state object contains the main data object of the application. Anything that changes in the state object will re-render the component.

The related method to set a specific key in the state is setState. The set state could be called after componentDidMount is called.

 

    constructor(props) {
      super(props);
      this.state = { products: [...] };
    }

    componentDidMount() {
      ....
      this.setState({products});
      .....
    }