react-native-router icon indicating copy to clipboard operation
react-native-router copied to clipboard

Allow the passing of props and bumped dependency versions

Open MikaelCarpenter opened this issue 10 years ago • 2 comments

Why

props

Originally had to pass data object and call it via this.props.data.myProp which seems unnecessary.

dependencies

If you had a recent version of react-native, you would get errors when running npm start

Unable to resolve module ./base64-vlq from /Users/mikaelcarpenter/gears-native/node_modules/react-native-router/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/SourceMap.js

{so on and so on}

What

props

Instead of passing data in your route, you can now pass passProps which takes in an object, and then creates a prop for each key: value pair in the object.

dependencies

Updated the version numbers in package.json dependencies.

This is also an update to a previous PR (#47) by wenkesj

Issue

Props #39 Dependencies #53

Example

_initialRoute = {
    name: 'Title'
    component: Home
    passProps: {
        prop1: 'hi'
        prop2: 'bye'
    }
}

App = React.createClass({
    render: function() {
        return (
            <Router firstRoute={_initialRoute} />
        )
    }
})

module.exports = App

Your Home component can now use this.props.prop1 and this.props.prop2

MikaelCarpenter avatar Jul 31 '15 20:07 MikaelCarpenter

@t4t5 :D

also for anyone wanting to make these changes manually to their project. After updating the dependencies: cd node_modules/react-native-router and npm update to apply the changes

MikaelCarpenter avatar Jul 31 '15 20:07 MikaelCarpenter

@jhabdas I haven't checked it out yet, but would you want to use it for the nav bar transitions rather than the opacity from tween-state?

MikaelCarpenter avatar Sep 03 '15 01:09 MikaelCarpenter