Skip to content

Instantly share code, notes, and snippets.

View AdamLenda's full-sized avatar
💭
So many ideas, so little time

Adam Lenda AdamLenda

💭
So many ideas, so little time
  • Lenda Consulting, LLC
  • Richmond, VA
View GitHub Profile
@TyrealGray
TyrealGray / Lifecycle in React Native Component.md
Last active November 12, 2018 17:18
Lifecycle in React Native Component

Lifecycle in React Native Component

When we are developing our app, there are some features we always need to add, e.g. ListView components only refresh when the data in listItem is changed, initializing data before render function but not in the constructor function…

React Native component has already been implemented with many native optimization for us, but those features above are not. To do that, we need to override lifecycle function in React Native component.

The Component Lifecycle API

First of all, this is the official site docs about the API we could use:https://facebook.github.io/react/docs/react-component.html#the-component-lifecycle

The order of lifecycle should be: constructor() -> componentWillMount() -> render() -> componentDidMount() -> [ runtime loop ] -> componentWillUnmount()

@martinth
martinth / argparse_fileinput_demo.py
Created August 6, 2015 11:04
Read from stdin or files in Python (combining argparse and fileinput)
import argpase
import fileinput
if __name__ == '__main__':
parser = ArgumentParser()
parser.add_argument('--dummy', help='dummy argument')
parser.add_argument('files', metavar='FILE', nargs='*', help='files to read, if empty, stdin is used')
args = parser.parse_args()
# If you would call fileinput.input() without files it would try to process all arguments.